Alexander "Arav" Andreev 0717a2e3d3
In case a path continues, but no child was found then break out of main for loop.
It was a bug that when there are children in the next node, but no parameterised one,  having a non-existent path element caused the main loop to continue and firing an if pathLen == i+1 case like if there was a legit node found.
2023-08-11 18:36:13 +04:00
2023-05-26 04:06:35 +04:00
2023-05-26 04:06:35 +04:00
2023-07-23 23:26:35 +04:00
2023-05-28 04:00:54 +04:00

httpr

It is an implementation of yet another HTTP router.

The reason why this router was made is to be able to have pretty paths with parameters and regular endpoints at the same level. Like this:

GET /:a/:b
GET /assets/*filepath

In routers like httprouter this is not allowed.

This router is used like many others., example:

r := httpr.New()

r.Handler(http.MethodGet, "/", func(w http.ResponseWriter, r *http.Request) {
	...
})

r.ServeStatic("/assets/*filepath", http.FS(os.Dir(".")))

r.NotFoundHandler = func(w http.ResponseWriter, r *http.Request) {
	...
}

if err := http.ListenAndServe(":8000", r); err != nil {
	...
}
Description
Yet another HTTP router. But this one allows any combinations of regular and param segments for a path.
Readme 84 KiB
2023-09-20 03:46:41 +04:00
Languages
Go 100%