Split code in respective files.

Resource method name change.

Route list func
This commit is contained in:
2025-08-16 11:19:45 +05:30
parent f91090b35e
commit 855b82e9df
10 changed files with 506 additions and 366 deletions

19
stack.go Normal file
View File

@@ -0,0 +1,19 @@
package mux
import "net/http"
// stack middlewares(http handler) in order they are passed (FIFO)
func stack(middlewares []func(http.Handler) http.Handler, endpoint http.Handler) http.Handler {
// Return ahead of time if there aren't any middlewares for the chain
if len(middlewares) == 0 {
return endpoint
}
// wrap the end handler with the middleware chain
h := middlewares[len(middlewares)-1](endpoint)
for i := len(middlewares) - 2; i >= 0; i-- {
h = middlewares[i](h)
}
return h
}