Recruit developers to build the kv database engine NutsDB together 招募开发者一起共建开源的KV数据库引擎NutsDB,有想法联系我。(wechat:xujiajun1234567,备注:nutsdb)
Project address:https://github.com/nutsdb/nutsdb
Hope to build nutsdb together(希望共建nutsdb):nutsdb/nutsdb#116
xujiajun/gorouter is a simple and fast HTTP router for Go. It is easy to build RESTful APIs and your web framework.
Home Page: https://xujiajun.cn/gorouter
License: MIT License
Recruit developers to build the kv database engine NutsDB together 招募开发者一起共建开源的KV数据库引擎NutsDB,有想法联系我。(wechat:xujiajun1234567,备注:nutsdb)
Project address:https://github.com/nutsdb/nutsdb
Hope to build nutsdb together(希望共建nutsdb):nutsdb/nutsdb#116
see https://github.com/xujiajun/gorouter/releases/tag/v1.2.0 for detail.
If inscribe.
非常棒的项目,简单明了,准备参照你的这个项目实现一个路由器。
Your current benchmark doesn't say which CPU model you're using for the benchmark. This is probably the most important part to include. I assume you're running some pre 7th-gen Intel i5/i7 CPU since it's on a Mac with DDR3 RAM.
Benchmark System:
Go Version : go1.11.2 darwin/amd64
OS: Mac OS X 10.13.6
Architecture: x86_64
RAM; 16 GB 2133 MHz LPDDR3
CPU: ???
比如在assets目录下有不一定的几层目录,现在这样好像处理不了,要一层一层写?
Currently your benchmark code does the following:
func benchRoutes(b *testing.B, router http.Handler, routes []route) {
b.N = 10000
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
for _, route := range routes {
router.ServeHTTP(httptest.NewRecorder(), httptest.NewRequest(route.method, route.path, nil))
}
}
}
The critical part is the router.ServeHTTP(httptest.NewRecorder(), httptest.NewRequest(route.method, route.path, nil))
within the loop, meaning that you allocate and initialize a new Recorder and a Request in every loop iteration.
Unfortunately that is likely much more expensive than the actual routing, meaning that both the measured memory cost and the execution time are completely meaningless, since there is a huge baseline cost.
user need to add url partern for every depth folder ?
is there a short way to match a total folder as below
// FileSystem custom file system handler
type FileSystem struct {
fs http.FileSystem
}
// Open opens file
func (fs FileSystem) Open(path string) (http.File, error) {
f, err := fs.fs.Open(path)
if err != nil {
return nil, err
}
s, err := f.Stat()
if s.IsDir() {
index := strings.TrimSuffix(path, "/") + "/index.html"
if _, err := fs.fs.Open(index); err != nil {
return nil, err
}
}
return f, nil
}
fileServer := http.FileServer(FileSystem{http.Dir(".")})
http.Handle("/static/", http.StripPrefix(strings.TrimRight("/static/", "/"), fileServer))
I like the idea of this router, and I'm planning on using it for an upcoming project. However the automatic regex matching for :id
and :name
is bothering me. I don't want to use it, and if I do, I'll provide my own regex. How do I prevent any regex matching from happening for those parameters?
I don't think it's a good idea to assume the regex that people want to use for random parameters, it can cause bugs and other problems. But that's just my opinion.
Router always return 404 response header
"Hello world!" run the same with error code.
# go version
go version go1.13.7 linux/amd64
# curl localhost:8181
hello world
# curl localhost:8181 -I
HTTP/1.1 404 Not Found
已经解决了。。。。。
Your router looks very attractive from a performance perspective.
But it looks like it is missing a very important feature for REST API that is reverse routing.
I am widely using gorilla/mux along with its reverse routing right now and would like to find a faster alternative for it.
If your router would have this feature, it would be very useful.
see https://github.com/xujiajun/gorouter/releases/tag/v1.1.0 for detail.
like url: http://localhost:8080/abc?id=123
how to get the 123
or should I get it from http.request directly ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.