aerogo / aero

:bullettrain_side: High-performance web server for Go (2016). New alpha (2024) with even better performance is currently in development at https://git.akyoto.dev/go/web
MIT License
572 stars 33 forks source link

static path match error #20

Closed kiyonlin closed 4 years ago

kiyonlin commented 4 years ago

Hi, I'm wondering if the static path match (tree.go#L29-L37 and tree.go#L121-L128) is wrong?

Here is the code snippet:

package main

import "github.com/aerogo/aero"

func main() {
    app := aero.New()
    app.Get("/:a/b/c", func(c aero.Context) error {
        return c.String("param a")
    })
    app.Get("/a/b/c", func(c aero.Context) error {
        return c.String("const a")
    })
    app.Run()
}

And request result:

http :4000/a/b/c
HTTP/1.1 200 OK
Content-Length: 7
Content-Type: text/plain; charset=utf-8
Date: Fri, 14 Aug 2020 11:24:04 GMT

const a
akyoto commented 4 years ago

Late reply, but that's actually a feature, see Explanation. The order of statements is irrelevant to the router and static paths have the highest priority.