internal/middleware: fix again

This commit is contained in:
Cadey Ratio 2018-01-21 09:01:22 -08:00
parent 143a2f8e3f
commit e7d494513d
1 changed files with 7 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package middleware
import (
"context"
"net/http"
"github.com/Xe/ln"
@ -11,9 +12,14 @@ import (
func Twirp(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
if ctx == nil {
panic("context is nil")
}
ctx, err := twirp.WithHTTPRequestHeaders(ctx, r.Header)
if err != nil {
ln.Error(ctx, err, ln.Action("can't get request headers"))
ln.Error(context.Background(), err, ln.Action("can't get request headers"))
http.Error(w, err.Error(), http.StatusInternalServerError)
}