♻️ Improved metadata endpoint support
This commit is contained in:
parent
9078c72874
commit
d67279438a
|
@ -1,11 +1,11 @@
|
||||||
package http
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
|
|
||||||
"github.com/fasthttp/router"
|
"github.com/fasthttp/router"
|
||||||
|
"github.com/goccy/go-json"
|
||||||
http "github.com/valyala/fasthttp"
|
http "github.com/valyala/fasthttp"
|
||||||
|
|
||||||
|
"source.toby3d.me/toby3d/middleware"
|
||||||
"source.toby3d.me/website/indieauth/internal/common"
|
"source.toby3d.me/website/indieauth/internal/common"
|
||||||
"source.toby3d.me/website/indieauth/internal/domain"
|
"source.toby3d.me/website/indieauth/internal/domain"
|
||||||
)
|
)
|
||||||
|
@ -103,7 +103,11 @@ func NewRequestHandler(config *domain.Config) *RequestHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *RequestHandler) Register(r *router.Router) {
|
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) {
|
func (h *RequestHandler) read(ctx *http.RequestCtx) {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package http_test
|
package http_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/fasthttp/router"
|
"github.com/fasthttp/router"
|
||||||
|
"github.com/goccy/go-json"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
http "github.com/valyala/fasthttp"
|
http "github.com/valyala/fasthttp"
|
||||||
|
@ -33,7 +33,7 @@ func TestMetadata(t *testing.T) {
|
||||||
assert.Equal(t, &delivery.MetadataResponse{
|
assert.Equal(t, &delivery.MetadataResponse{
|
||||||
AuthorizationEndpoint: cfg.Server.GetRootURL() + "authorize",
|
AuthorizationEndpoint: cfg.Server.GetRootURL() + "authorize",
|
||||||
Issuer: cfg.Server.GetRootURL(),
|
Issuer: cfg.Server.GetRootURL(),
|
||||||
ServiceDocumentation: "https://indieauth.spec.indieweb.org/",
|
ServiceDocumentation: "https://indieauth.net/source/",
|
||||||
TokenEndpoint: cfg.Server.GetRootURL() + "token",
|
TokenEndpoint: cfg.Server.GetRootURL() + "token",
|
||||||
AuthorizationResponseIssParameterSupported: true,
|
AuthorizationResponseIssParameterSupported: true,
|
||||||
GrantTypesSupported: []string{
|
GrantTypesSupported: []string{
|
||||||
|
|
Loading…
Reference in New Issue