Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(middleware): add a middleware to set the content-type to application/json #97

Merged
merged 4 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## To be Released

* feat(middleware): add a middleware to set the content-type to application/json
SCedricThomas marked this conversation as resolved.
Show resolved Hide resolved

## v1.8.1

* feat(errors): add bad request errors
Expand Down
12 changes: 12 additions & 0 deletions content_type_middleware.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package handlers

import (
"net/http"
)

var JSONContentTypeMiddleware = MiddlewareFunc(func(handler HandlerFunc) HandlerFunc {
SCedricThomas marked this conversation as resolved.
Show resolved Hide resolved
return func(w http.ResponseWriter, r *http.Request, vars map[string]string) error {
w.Header().Set("Content-Type", "application/json")
return nil
}
})