chore(http): export NewBaseChiRouter constructor

pull/18522/head
Johnny Steenbergen 2020-06-15 15:18:13 -07:00 committed by Johnny Steenbergen
parent 4790c3cb43
commit 2c85e1520f
2 changed files with 3 additions and 2 deletions

View File

@ -121,7 +121,7 @@ func WithResourceHandler(resHandler kithttp.ResourceHandler) APIHandlerOptFn {
// NewAPIHandler constructs all api handlers beneath it and returns an APIHandler // NewAPIHandler constructs all api handlers beneath it and returns an APIHandler
func NewAPIHandler(b *APIBackend, opts ...APIHandlerOptFn) *APIHandler { func NewAPIHandler(b *APIBackend, opts ...APIHandlerOptFn) *APIHandler {
h := &APIHandler{ h := &APIHandler{
Router: newBaseChiRouter(b.HTTPErrorHandler), Router: NewBaseChiRouter(b.HTTPErrorHandler),
} }
noAuthUserResourceMappingService := b.UserResourceMappingService noAuthUserResourceMappingService := b.UserResourceMappingService

View File

@ -28,7 +28,8 @@ func NewRouter(h platform.HTTPErrorHandler) *httprouter.Router {
return router return router
} }
func newBaseChiRouter(errorHandler platform.HTTPErrorHandler) chi.Router { // NewBaseChiRouter returns a new chi router with a 404 handler, a 405 handler, and a panic handler.
func NewBaseChiRouter(errorHandler platform.HTTPErrorHandler) chi.Router {
router := chi.NewRouter() router := chi.NewRouter()
bh := baseHandler{HTTPErrorHandler: errorHandler} bh := baseHandler{HTTPErrorHandler: errorHandler}
router.NotFound(bh.notFound) router.NotFound(bh.notFound)