Skip to content
This repository has been archived by the owner on Dec 25, 2022. It is now read-only.
/ baserouter Public archive

http多路分解库,支持定义path变量与解析。这是一种新的尝试,哈哈。(TODO)不建议使用。。。

License

Notifications You must be signed in to change notification settings

1whour/baserouter

Repository files navigation

baserouter

baserouter和httprouter定位是比较类似的库,借鉴了httprouter的API设计,底层使用不同的算法和数据结构,它是一种新的尝试,看性能上能否更快

Go codecov

feature

近似零拷贝 只有在需要分配参数,才有可能从堆上分配内存。

高性能 现在某些指标目前比httprouter慢10ns

quick start

package main

import (
    "fmt"
    "net/http"
    "log"

    "github.com/antlabs/baserouter"
)

func Index(w http.ResponseWriter, r *http.Request, _ baserouter.Params) {
	fmt.Fprint(w, "Welcome!\n")
}

func Hello(w http.ResponseWriter, r *http.Request, ps baserouter.Params) {
	fmt.Fprintf(w, "hello, %s!\n", ps.ByName("name"))
}

func main() {
    router := baserouter.New()
    router.GET("/", Index)
    router.GET("/hello/:name", Hello)

    log.Fatal(http.ListenAndServe(":8080", router))
}

About

http多路分解库,支持定义path变量与解析。这是一种新的尝试,哈哈。(TODO)不建议使用。。。

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages