fix: use xmlResponse
This commit is contained in:
parent
b798f4ce86
commit
7f76df0b24
2 changed files with 1 additions and 12 deletions
|
@ -5,7 +5,6 @@ package context
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/xml"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -137,16 +136,6 @@ func (b *Base) JSON(status int, content any) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// XML render content as XML
|
|
||||||
func (b *Base) XML(status int, content any) {
|
|
||||||
b.Resp.Header().Set("Content-Type", "application/xml;charset=utf-8")
|
|
||||||
b.Resp.WriteHeader(status)
|
|
||||||
b.Resp.Write([]byte(xml.Header))
|
|
||||||
if err := xml.NewEncoder(b.Resp).Encode(content); err != nil {
|
|
||||||
log.Error("Render XML failed: %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemoteAddr returns the client machine ip address
|
// RemoteAddr returns the client machine ip address
|
||||||
func (b *Base) RemoteAddr() string {
|
func (b *Base) RemoteAddr() string {
|
||||||
return b.Req.RemoteAddr
|
return b.Req.RemoteAddr
|
||||||
|
|
|
@ -412,7 +412,7 @@ func DownloadPackageFile(ctx *context.Context) {
|
||||||
Metadata: pd.Metadata.(*nuget_module.Metadata),
|
Metadata: pd.Metadata.(*nuget_module.Metadata),
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.XML(http.StatusOK, nuget_module.GenerateNuspec(pkg))
|
xmlResponse(ctx, http.StatusOK, nuget_module.GenerateNuspec(pkg))
|
||||||
} else {
|
} else {
|
||||||
s, u, pf, err := packages_service.GetFileStreamByPackageNameAndVersion(
|
s, u, pf, err := packages_service.GetFileStreamByPackageNameAndVersion(
|
||||||
ctx,
|
ctx,
|
||||||
|
|
Loading…
Add table
Reference in a new issue