package routers

import (
	"context"
	"net/http"

	"github.com/go-chi/chi/v5"
	"github.com/tech/sendico/pkg/mlogger"
	"github.com/tech/sendico/pkg/model"
	"github.com/tech/sendico/server/interface/api/sresponse"
	"github.com/tech/sendico/server/interface/middleware"
)

type (
	RegistratorT  = func(chi.Router, string, http.HandlerFunc)
	ResponderFunc = func(ctx context.Context, r *http.Request, session *model.SessionIdentifier, account *model.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
}
