internal/middleware: fix again
This commit is contained in:
parent
143a2f8e3f
commit
e7d494513d
|
@ -1,6 +1,7 @@
|
||||||
package middleware
|
package middleware
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/Xe/ln"
|
"github.com/Xe/ln"
|
||||||
|
@ -11,9 +12,14 @@ 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()
|
||||||
|
|
||||||
|
if ctx == nil {
|
||||||
|
panic("context is nil")
|
||||||
|
}
|
||||||
|
|
||||||
ctx, err := twirp.WithHTTPRequestHeaders(ctx, r.Header)
|
ctx, err := twirp.WithHTTPRequestHeaders(ctx, r.Header)
|
||||||
if err != nil {
|
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)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue