google / go-safeweb

Secure-by-default HTTP servers in Go.
Apache License 2.0
1.43k stars 81 forks source link

Muxes are not composable #332

Open empijei opened 3 years ago

empijei commented 3 years ago

A nice feature of http.Mux is that it can be used as a handler, so users can set up separate parts of an application on separate muxes that share a common configuration (e.g. a set of interceptors) and then install them on the root mux.

This is currently not possible with GSW, and we should seriously consider doing it.

kele commented 2 years ago

To clarify, you are not referring to the safehttp.ServeMux being composable with http.Mux, but with itself, i.e.:

var m1 safehttp.ServeMux
var m2 safehttp.ServeMux

var rootMux safehttp.ServeMux
// These two lines below would not compile.
rootMux.Handle(..., m1)
rootMux.Handle(..., m2)

Correct?

empijei commented 2 years ago

Correct.