Skip to content

Commit

Permalink
fix(issue-34): support only allow http2 requests if config is set
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaba505 committed Dec 18, 2023
1 parent d5459f4 commit d8f356f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,13 @@ func (rt *Runtime) Run(ctx context.Context) error {

s := &http.Server{
Handler: otelhttp.NewHandler(
rt.h,
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if rt.http2Only && r.ProtoMajor < 2 {
w.WriteHeader(http.StatusUnauthorized)
return
}
rt.h.ServeHTTP(w, r)
}),
"server",
otelhttp.WithMessageEvents(otelhttp.ReadEvents, otelhttp.WriteEvents),
),
Expand Down

0 comments on commit d8f356f

Please sign in to comment.