middleware/app_info.go
2020-09-30 19:40:06 +03:00

20 lines
428 B
Go

package middleware
import (
"net/http"
)
// AppInfo adds application name and version headers to the response
func AppInfo(name string, version string) func(http.Handler) http.Handler {
return func(h http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("App-Name", name)
w.Header().Set("App-Version", version)
h.ServeHTTP(w, r)
}
return http.HandlerFunc(fn)
}
}