feat(smalltrip): use multiplexer interface instead of http.ServeMux

This will be useful for the future to provide something akin to
plugins/addons to the router.
This commit is contained in:
Guz
2025-06-27 22:02:39 -03:00
parent 3fc9631fbc
commit 7ae5c14f6c
3 changed files with 33 additions and 10 deletions

View File

@@ -16,27 +16,22 @@
package smalltrip
import (
"fmt"
"io"
"log/slog"
"net/http"
"path"
"strings"
"forge.capytal.company/loreddev/x/smalltrip/middleware"
"forge.capytal.company/loreddev/x/tinyssert"
"forge.capytal.company/loreddev/x/smalltrip/multiplexer"
)
type Router interface {
Handle(pattern string, handler http.Handler)
HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
Use(middleware middleware.Middleware)
http.Handler
multiplexer.Multiplexer
Use(middleware.Middleware)
}
type router struct {
mux *http.ServeMux
mux multiplexer.Multiplexer
mws []middleware.Middleware
log *slog.Logger
}