feat(smallstrip): WithMiddleware option
This commit is contained in:
@@ -17,27 +17,24 @@ package smalltrip
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"net/http"
|
||||
|
||||
"forge.capytal.company/loreddev/x/tinyssert"
|
||||
"forge.capytal.company/loreddev/x/smalltrip/middleware"
|
||||
)
|
||||
|
||||
type Option func(*router)
|
||||
|
||||
func WithAssertions(assertions tinyssert.Assertions) Option {
|
||||
return func(r *router) {
|
||||
r.assert = assertions
|
||||
}
|
||||
}
|
||||
|
||||
func WithLogger(logger *slog.Logger) Option {
|
||||
return func(r *router) {
|
||||
r.log = logger
|
||||
}
|
||||
}
|
||||
|
||||
func WithServeMux(mux *http.ServeMux) Option {
|
||||
return func(r *router) {
|
||||
r.mux = mux
|
||||
}
|
||||
}
|
||||
|
||||
func WithMiddleware(m middleware.Middleware) Option {
|
||||
return func(r *router) {
|
||||
r.Use(m)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user