This repository has been archived on 2026-09-13. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files

32 lines
830 B
Go

package httpapi
import (
"errors"
"net/http"
"github.com/go-chi/chi/v5"
)
type Endpoints struct {
Metadata http.Handler
Token http.Handler
JWKS http.Handler
Health http.Handler
Ready http.Handler
}
func NewRouter(endpoints Endpoints) (http.Handler, error) {
if endpoints.Metadata == nil || endpoints.Token == nil || endpoints.JWKS == nil || endpoints.Health == nil || endpoints.Ready == nil {
return nil, errors.New("all HTTP endpoints are required")
}
router := chi.NewRouter()
router.Get("/.well-known/oauth-authorization-server", endpoints.Metadata.ServeHTTP)
router.Post("/oauth2/token", endpoints.Token.ServeHTTP)
router.Get("/oauth2/jwks", endpoints.JWKS.ServeHTTP)
router.Get("/healthz", endpoints.Health.ServeHTTP)
router.Get("/readyz", endpoints.Ready.ServeHTTP)
return router, nil
}