M
M
Mikkkch2020-10-09 17:46:05
go
Mikkkch, 2020-10-09 17:46:05

How to use context when working with API using fasthttp?

Hello, at the moment I am writing a small lib to work with the API and I saw that in order to work with apish, it is required to add context.Context to my code because it is intended for this.

To prevent the library from being sluggish, I use fasthttp. Unfortunately the Request type in fasthttp does not have a WithContext method like in net/http.

Perhaps someone knows how you can use the context by sending requests to the api server using fast.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Papa, 2020-10-09
Stifflera @PapaStifflera

Why do you need fasthttp? Do you have some kind of fierce highload planned? If you do not plan to process more than 300K rps, just take net / http + some kind of normal router and do not suffer.

S
sotanodroid, 2020-10-10
@sotanodroid

You can implement your own methods that will use the context and then call methods from the framework. Another question is that it is not clear how exactly the context will be used and what is the purpose of using fasthttp and the context as such, perhaps the standard net / http and the gorilla mux multiplexer will be enough

I
Ivan Shalganov, 2020-10-22
@Aco

fasthttp.RequestCtx is a context, it implements all methods of the Context interface and can be used as a context where a context.Context object is needed. If I understand correctly what you need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question