middleware/app_info.go

20 lines
428 B
Go
Raw Normal View History

2020-09-30 16:40:06 +00:00
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)
}
}