38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
package endpoint
|
|
|
|
import (
|
|
"context"
|
|
customermodel "git.sendico.io/tech/sxchnge/product/customers/model"
|
|
sessionmodel "git.sendico.io/tech/sxchnge/product/sessions/model"
|
|
"net/http"
|
|
|
|
"git.sendico.io/tech/sxchnge/product/auth/config"
|
|
"git.sendico.io/tech/sxchnge/product/auth/response"
|
|
"git.sendico.io/tech/sxchnge/shared/logging"
|
|
"github.com/go-chi/chi/v5"
|
|
)
|
|
|
|
type (
|
|
RegistratorT = func(chi.Router, string, http.HandlerFunc)
|
|
ResponderFunc = func(ctx context.Context, r *http.Request, session *sessionmodel.SessionIdentifier, account *customermodel.Account, accessToken *sresponse.TokenData) http.HandlerFunc
|
|
)
|
|
|
|
type HttpEndpointRouter struct {
|
|
logger mlogger.Logger
|
|
apiEndpoint string
|
|
router chi.Router
|
|
config middleware.TokenConfig
|
|
signature middleware.Signature
|
|
}
|
|
|
|
func NewHttpEndpointRouter(logger mlogger.Logger, apiEndpoint string, router chi.Router, config *middleware.TokenConfig, signature *middleware.Signature) *HttpEndpointRouter {
|
|
er := HttpEndpointRouter{
|
|
logger: logger.Named("http"),
|
|
apiEndpoint: apiEndpoint,
|
|
router: router,
|
|
signature: *signature,
|
|
config: *config,
|
|
}
|
|
return &er
|
|
}
|