1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-08-26 18:20:57 +00:00

feat(nuget): basic manifest download

This commit is contained in:
Michael Kriese 2024-01-23 22:42:46 +01:00
parent 9fe826605f
commit 5f837efc15
No known key found for this signature in database
GPG key ID: B83F553A0724D44E
3 changed files with 127 additions and 46 deletions

View file

@ -5,6 +5,7 @@ package context
import (
"context"
"encoding/xml"
"fmt"
"io"
"net/http"
@ -136,6 +137,15 @@ 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)
if err := xml.NewEncoder(b.Resp).Encode(content); err != nil {
log.Error("Render XML failed: %v", err)
}
}
// RemoteAddr returns the client machine ip address
func (b *Base) RemoteAddr() string {
return b.Req.RemoteAddr