Capstan is a Golang web framework that shares some similarities with others in its segment.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
421B

  1. package middleware
  2. import (
  3. "net/http"
  4. "strings"
  5. )
  6. func MangleHeader(name string) func(http.Handler) http.Handler {
  7. return func(next http.Handler) http.Handler {
  8. fn := func(w http.ResponseWriter, r *http.Request) {
  9. header := strings.ToUpper(r.Header.Get(name))
  10. if header != "" && header != r.Method {
  11. r.Method = strings.ToUpper(header)
  12. }
  13. next.ServeHTTP(w, r)
  14. }
  15. return http.HandlerFunc(fn)
  16. }
  17. }