♻️ Improved metadata endpoint support

This commit is contained in:
Maxim Lebedev 2022-01-14 01:43:07 +05:00
parent 9078c72874
commit d67279438a
Signed by: toby3d
GPG Key ID: 1F14E25B7C119FC5
2 changed files with 9 additions and 5 deletions

View File

@ -1,11 +1,11 @@
package http
import (
"encoding/json"
"github.com/fasthttp/router"
"github.com/goccy/go-json"
http "github.com/valyala/fasthttp"
"source.toby3d.me/toby3d/middleware"
"source.toby3d.me/website/indieauth/internal/common"
"source.toby3d.me/website/indieauth/internal/domain"
)
@ -103,7 +103,11 @@ func NewRequestHandler(config *domain.Config) *RequestHandler {
}
func (h *RequestHandler) Register(r *router.Router) {
r.GET("/.well-known/oauth-authorization-server", h.read)
chain := middleware.Chain{
middleware.LogFmt(),
}
r.GET("/.well-known/oauth-authorization-server", chain.RequestHandler(h.read))
}
func (h *RequestHandler) read(ctx *http.RequestCtx) {

View File

@ -1,10 +1,10 @@
package http_test
import (
"encoding/json"
"testing"
"github.com/fasthttp/router"
"github.com/goccy/go-json"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
http "github.com/valyala/fasthttp"
@ -33,7 +33,7 @@ func TestMetadata(t *testing.T) {
assert.Equal(t, &delivery.MetadataResponse{
AuthorizationEndpoint: cfg.Server.GetRootURL() + "authorize",
Issuer: cfg.Server.GetRootURL(),
ServiceDocumentation: "https://indieauth.spec.indieweb.org/",
ServiceDocumentation: "https://indieauth.net/source/",
TokenEndpoint: cfg.Server.GetRootURL() + "token",
AuthorizationResponseIssParameterSupported: true,
GrantTypesSupported: []string{