Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@ func (api *API) RecoveryMiddleware(h http.Handler) http.Handler {
func (api *API) CompressionMiddleware(h http.Handler) http.Handler {
return handlers.CompressHandlerLevel(h, api.conf.GzipLevel)
}

// MethodOverrideMiddleware allows clients who can not perform native PUT, PATCH,
// or DELETE requests to specify the HTTP method in the X-HTTP-Method-Override
// header. The header name is case sensitive.
func (api *API) MethodOverrideMiddleware(h http.Handler) http.Handler {
return handlers.HTTPMethodOverrideHandler(h)
}
4 changes: 4 additions & 0 deletions middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ func (suite *HyperdriveTestSuite) TestRecoveryMiddleware() {
func (suite *HyperdriveTestSuite) TestCompressionMiddleware() {
suite.Implements((*http.Handler)(nil), suite.TestAPI.CompressionMiddleware(suite.TestHandler), "return an implementation of http.Handler")
}

func (suite *HyperdriveTestSuite) TestMethodOverrideMiddleware() {
suite.Implements((*http.Handler)(nil), suite.TestAPI.MethodOverrideMiddleware(suite.TestHandler), "return an implementation of http.Handler")
}