This commit is contained in:
Nazar Kanaev 2021-03-19 00:06:48 +00:00
parent 391ce61362
commit 9f376db0f4
24 changed files with 65 additions and 67 deletions

View file

@ -10,10 +10,10 @@ import (
)
type Context struct {
Req *http.Request
Out http.ResponseWriter
Req *http.Request
Out http.ResponseWriter
Vars map[string]string
Vars map[string]string
chain []Handler
index int

View file

@ -55,7 +55,7 @@ func TestRouteRegexpStar(t *testing.T) {
func TestRegexGroupsPart(t *testing.T) {
re := routeRegexp("/foo/:bar/1/:baz")
expect := map[string]string{"bar": "one", "baz": "two"}
actual := regexGroups("/foo/one/1/two", re)
@ -66,7 +66,7 @@ func TestRegexGroupsPart(t *testing.T) {
func TestRegexGroupsStar(t *testing.T) {
re := routeRegexp("/foo/*bar")
expect := map[string]string{"bar": "bar/baz/"}
actual := regexGroups("/foo/bar/baz/", re)

View file

@ -51,7 +51,7 @@ func (r *Router) resolve(path string) *Route {
func (r *Router) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
// autoclose open base url
if r.base != "" && r.base == req.URL.Path {
http.Redirect(rw, req, r.base + "/", http.StatusFound)
http.Redirect(rw, req, r.base+"/", http.StatusFound)
return
}