Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package chi
import "net/http"

// Chain returns a Middlewares type from a slice of middleware handlers.
func Chain(middlewares ...func(http.Handler) http.Handler) Middlewares {
func Chain(middlewares Middlewares) Middlewares {
return Middlewares(middlewares)
}

Expand Down Expand Up @@ -33,7 +33,7 @@ func (c *ChainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {

// chain builds a http.Handler composed of an inline middleware stack and endpoint
// handler in the order they are passed.
func chain(middlewares []func(http.Handler) http.Handler, endpoint http.Handler) http.Handler {
func chain(middlewares Middlewares, endpoint http.Handler) http.Handler {
// Return ahead of time if there aren't any middlewares for the chain
if len(middlewares) == 0 {
return endpoint
Expand Down
5 changes: 5 additions & 0 deletions chi.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ func NewRouter() *Mux {
return NewMux()
}

// middleware type alias (for chain.go)
type Middleware = func(http.Handler) http.Handler

type Middlewares Middleware[]

// Router consisting of the core routing methods used by chi's Mux,
// using only the standard net/http.
type Router interface {
Expand Down