From d67279438a040bdbace3f5b8385b81c064798391 Mon Sep 17 00:00:00 2001 From: Maxim Lebedev Date: Fri, 14 Jan 2022 01:43:07 +0500 Subject: [PATCH] :recycle: Improved metadata endpoint support --- internal/metadata/delivery/http/metadata_http.go | 10 +++++++--- internal/metadata/delivery/http/metadata_http_test.go | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/internal/metadata/delivery/http/metadata_http.go b/internal/metadata/delivery/http/metadata_http.go index f3877f0..a2abad2 100644 --- a/internal/metadata/delivery/http/metadata_http.go +++ b/internal/metadata/delivery/http/metadata_http.go @@ -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) { diff --git a/internal/metadata/delivery/http/metadata_http_test.go b/internal/metadata/delivery/http/metadata_http_test.go index 1f32cdc..a6a111d 100644 --- a/internal/metadata/delivery/http/metadata_http_test.go +++ b/internal/metadata/delivery/http/metadata_http_test.go @@ -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{