diff --git a/server.go b/server.go index 8fec25c..295f73f 100644 --- a/server.go +++ b/server.go @@ -10,19 +10,25 @@ import ( type Server struct { *http.ServeMux - Logger log.Logger + basePath string + Logger log.Logger } -func NewServer(mux *http.ServeMux, logger log.Logger) *Server { +func NewServer(mux *http.ServeMux, basePath string, logger log.Logger) *Server { if mux == nil { mux = http.NewServeMux() } return &Server{ ServeMux: mux, + basePath: basePath, Logger: logger, } } +func (s *Server) Handle(pattern string, handler http.Handler) { + s.ServeMux.Handle(s.basePath+pattern, handler) +} + func (s *Server) RegisterCallbackServer(srv server.CallbackServer) { s.Handle(server.CallbackEndpoint, server.NewServer(server.CallbackRequest{}, []string{http.MethodPost}, s.Logger, func(req server.Request) (res server.Response, errRes server.ErrorResponse) { callbackRequest, ok := req.(*server.CallbackRequest)