internal/middleware: fix twirp

This commit is contained in:
Cadey Ratio 2018-01-21 08:57:35 -08:00
parent 2f92dfbe46
commit 143a2f8e3f
1 changed files with 6 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package middleware
import ( import (
"net/http" "net/http"
"github.com/Xe/ln"
"github.com/twitchtv/twirp" "github.com/twitchtv/twirp"
) )
@ -10,7 +11,11 @@ import (
func Twirp(next http.Handler) http.Handler { func Twirp(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context() ctx := r.Context()
ctx, _ = twirp.WithHTTPRequestHeaders(ctx, r.Header) ctx, err := twirp.WithHTTPRequestHeaders(ctx, r.Header)
if err != nil {
ln.Error(ctx, err, ln.Action("can't get request headers"))
http.Error(w, err.Error(), http.StatusInternalServerError)
}
next.ServeHTTP(w, r.WithContext(ctx)) next.ServeHTTP(w, r.WithContext(ctx))
}) })