fah/middlewares.go
masilux edc2f290d9 + in mehreren Dateien unterteilt
+ Programm umbenannt in fah (Formularausfüllhilfe)
2024-10-30 00:03:39 +01:00

18 lines
347 B
Go

package main
import (
"fmt"
"net/http"
"strings"
)
func jsonHeaderMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Println(r.URL.Path)
if strings.HasPrefix(r.URL.Path, "/api/") {
w.Header().Add("Content-Type", "application/json")
}
next.ServeHTTP(w, r)
})
}