mirror of
https://github.com/versia-pub/versia-go.git
synced 2026-03-13 04:29:15 +01:00
refactor!: working WD-4 user discovery
This commit is contained in:
parent
cf0053312d
commit
61891d891a
91 changed files with 12768 additions and 5562 deletions
32
internal/utils/fiber.go
Normal file
32
internal/utils/fiber.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/valyala/fasthttp/fasthttpadaptor"
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func ConvertToStdRequest(c *fiber.Ctx) (*http.Request, error) {
|
||||
stdReq := &http.Request{}
|
||||
if err := fasthttpadaptor.ConvertRequest(c.Context(), stdReq, true); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return stdReq, nil
|
||||
}
|
||||
|
||||
func CopyBody(req *http.Request) ([]byte, error) {
|
||||
body, err := io.ReadAll(req.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := req.Body.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req.Body = io.NopCloser(bytes.NewBuffer(body))
|
||||
return body, nil
|
||||
}
|
||||
|
|
@ -73,3 +73,23 @@ func NoteAPIURL(uuid uuid.UUID) *lysand.URL {
|
|||
newPath := &url.URL{Path: fmt.Sprintf("/api/notes/%s/", uuid.String())}
|
||||
return lysand.URLFromStd(config.C.PublicAddress.ResolveReference(newPath))
|
||||
}
|
||||
|
||||
func InstanceMetadataAPIURL() *lysand.URL {
|
||||
newPath := &url.URL{Path: "/.well-known/versia/"}
|
||||
return lysand.URLFromStd(config.C.PublicAddress.ResolveReference(newPath))
|
||||
}
|
||||
|
||||
func InstanceMetadataAdminsAPIURL() *lysand.URL {
|
||||
newPath := &url.URL{Path: "/.well-known/versia/admins/"}
|
||||
return lysand.URLFromStd(config.C.PublicAddress.ResolveReference(newPath))
|
||||
}
|
||||
|
||||
func InstanceMetadataModeratorsAPIURL() *lysand.URL {
|
||||
newPath := &url.URL{Path: "/.well-known/versia/moderators/"}
|
||||
return lysand.URLFromStd(config.C.PublicAddress.ResolveReference(newPath))
|
||||
}
|
||||
|
||||
func SharedInboxAPIURL() *lysand.URL {
|
||||
newPath := &url.URL{Path: "/api/inbox/"}
|
||||
return lysand.URLFromStd(config.C.PublicAddress.ResolveReference(newPath))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue