qiangxue / fasthttp-routing Goto Github PK
View Code? Open in Web Editor NEWA fast and powerful routing package for fasthttp servers
License: BSD 3-Clause "New" or "Revised" License
A fast and powerful routing package for fasthttp servers
License: BSD 3-Clause "New" or "Revised" License
As I pointed here the fasthttp-routing uses builtin Error()
function of fasthttp.RequestCtx
in it's handler (file report.go
lines 103
and 105
). This function however completely resets response which introduces problem e.g. when returning error 401 (it should return header WWW-Authenticate
in response and resetting response deletes all headers). Would it be possible to implement custom error handling function which would correctly print all user-set headers in response on error encounter?
你好,我发现目前route没有绑定指定域名的方法,想请教一下是否有考虑过支持呢
或者有什么能够自定义的方法吗?谢谢
What could I be doing wrong?
router := routing.New()
router.Use(func(req *routing.Context) error {
origin := string(req.Request.Header.Peek("Origin"))
if origin == "" {
origin = "*"
}
req.Response.Header.Set("Access-Control-Allow-Origin", origin)
req.Response.Header.Set("Access-Control-Allow-Credentials", "true")
req.Response.Header.Set("Access-Control-Allow-Methods", "GET,HEAD,PUT,POST,DELETE")
req.Response.Header.Set("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization")
return nil
})
I'm using router.Route("route name") method to get the path of the named route. As I understand it returns a &Route struct but path field is not accessible because not exported.
I like this function because is useful for reverse routing.
Is possible to get the path from named route?
func NotFoundHandler(ctx *routing.Context) error {
ctx.WriteString("Not Found:" + strconv.Itoa(http.StatusNotFound))
ctx.Response.SetStatusCode(http.StatusNotFound)
return routing.NewHTTPError(http.StatusNotFound)
}
Could you advise why not use fasthttp-routing to replace ozzo-routing in your ozzo framework if it is extremely fast?
Thanks.
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.