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>
This commit is contained in:
2026-06-24 23:42:57 +01:00
co-authored by Sisyphus
parent 08c8828bb0
commit da0e64c02b
3 changed files with 130 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
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)
})
}