mm is a middleware-middleware for multiple rules.
It provides middleware that changes the middlewares used based on the request.
Prepare an instance that implements mm.Builder
interface.
Then, generate the middleware ( func(next http.Handler) http.Handler
) with mm.New
package main
import (
"log"
"net/http"
"github.com/2manymws/mm"
)
func main() {
r := http.NewServeMux()
r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello World"))
})
var b mm.Builder = newMyBuilder()
m := mm.New(b)
log.Fatal(http.ListenAndServe(":8080", m(r)))
}