Files
Crussell/backend/mw/contenttype.go
T
popertotsandSisyphus da0e64c02b feat(mw): add content-type and response middleware
Add Content-Type enforcement middleware and generic JSON response helpers to standardize API responses.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-24 23:42:57 +01:00

14 lines
464 B
Go

package mw
import "net/http"
// JsonContentType sets Content-Type: application/json on all API responses.
// Individual handlers that need to override (e.g. binary/image responses)
// should set their own Content-Type header after this middleware runs.
func JsonContentType(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
next.ServeHTTP(w, r)
})
}