gohttp/server/directive.go

25 lines
538 B
Go
Raw Normal View History

package server
import "net/http"
type Directive func(args ...string) Middleware
var Add_Header Directive = func(args ...string) Middleware {
return func(w http.ResponseWriter, r *http.Request, next func()) {
w.Header().Add(args[0], args[1])
next()
}
}
var Set_Header Directive = func(args ...string) Middleware {
return func(w http.ResponseWriter, r *http.Request, next func()) {
w.Header().Set(args[0], args[1])
next()
}
}
var DirectiveMap = map[string]Directive{
"Set-Header": Set_Header,
"Add-Header": Add_Header,
}