Fasthttp: how to handle parameter in url

Created on 16 Nov 2016  路  6Comments  路  Source: valyala/fasthttp

I do not want to use any router and only use this fasthttp but i want to handle parameter in url like /hello/:name . How to do this? i can't find it in the examples. Thanks for this great framework

Most helpful comment

As @diegossilveira noted a router I can note a web framework which has exactly the same performance as fasthttp itself and you can access all 'fasthttp magic' context via ctx.RequestCtx so you have nothing to lose, take a look at: https://github.com/kataras/iris

And, @araneta your issue can be solved if you decide to use iris, code snippet: ctx.ParamInt("id")

All 6 comments

Fasthttp is http protocol implementation library mostly, not a rad web application framework as you may imagine, it gives you the basic and its really fast. So if you don't want to use existing fasthttp based web frameworks then you have to make your own 'router' to work with it.

fasthttp.ListenAndServe("mydomain.com:MYPORT", func(reqCtx *fasthttp.RequestCtx){
// here your logic for routing, you can find the url or path via reqCtx.Request.XXX 
// and call your registered handlers from here
})

As @kataras said, fasthttp is simply a really fast implementation of HTTP protocol.
There are a lot of web frameworks built atop of it, but if the only thing you need are routes (including path parameters parsing), take a look at https://github.com/buaazp/fasthttprouter.

@diegossilveira yes i have tried that library but i got this issue https://github.com/buaazp/fasthttprouter/issues/15
Thanks

As @diegossilveira noted a router I can note a web framework which has exactly the same performance as fasthttp itself and you can access all 'fasthttp magic' context via ctx.RequestCtx so you have nothing to lose, take a look at: https://github.com/kataras/iris

And, @araneta your issue can be solved if you decide to use iris, code snippet: ctx.ParamInt("id")

@araneta @kataras Marketing 鈽猴笍 (I lie both frameworks, really cool!)

@thalesfsp I don't know if your comment has bad attritube but I will answer, I am not snob!

I hope you see, with a second eye glitch, that I didn't marketing anything. At my first answer/comment I try to explain the fasthttp way, the second comment was just an answer to my friend @diegossilveira and a fix for the @araneta, not marketing at all.

Is good to know: Marketing doesn't makes good software, developers do.

Some history:

Iris was the first complete web framework backend by fasthttp (and still the only one, as far as I know, prove me wrong) and no other router or framework did that, risky(?), step[from nethttp to fasthttp] before , now they are shown up like flowers and I'm so proud about this, Iris put a hand on this too.

Personal(?) opinion:
I think most of you didn't know fasthttp at all or what fasthttp can do(or you scaried to use it) before Iris, right? If I 'am marketing' something that is the fasthttp itself, hope you understand this...

Fasthttp as protocol library finally takes the attention which deserves.

The comment was written as polite as I can, with my english, note that I am not native english speaker. Hopes you the best!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

facundomedica picture facundomedica  路  4Comments

LeMoussel picture LeMoussel  路  3Comments

AnikHasibul picture AnikHasibul  路  3Comments

jeremyjpj0916 picture jeremyjpj0916  路  5Comments

ohenepee picture ohenepee  路  4Comments