We have benchmarked the API and the performance of Fuego against other popular frameworks. The results are shown below.
Context | Fuego | net/http | gin | echo | FastHTTP | FastAPI | NestJS |
---|---|---|---|---|---|---|---|
query param | QueryParam(string) string |
r.URL.Query().Get("string") |
c.Query("string") |
c.QueryParam("string") |
c.QueryArgs().Peek("string") |
@app.get("/string") def string(string: str): |
@Get("/string") string(@QueryParam("string") string: string): |
path param | PathParam(string) string |
mux.Vars(r)["string"] |
c.Param("string") |
c.Param("string") |
c.Param("string") |
@app.get("/string") def string(string: str): |
@Get("/string") string(@Param("string") string: string): |
body | Body() T |
r.FormValue("string") |
c.PostForm("string") |
c.FormValue("string") |
c.PostArgs().Peek("string") |
@app.post("/string") def string(string: str): |
@Post("/string") string(@BodyParam("string") string: string): |
header | Header(string) string |
r.Header.Get("string") |
c.GetHeader("string") |
c.Request().Header.Get("string") |
c.Request().Header.Peek("string") |
@app.get("/string") def string(string: str): |
@Get("/string") string(@HeaderParam("string") string: string): |
cookie | Cookie(string) string |
r.Cookie("string") |
c.GetCookie("string") |
c.Cookie("string") |
c.Request().Header.Cookie("string") |
@app.get("/string") def string(string: str): |
@Get("/string") string(@CookieParam("string") string: string): |
context | Context() context.Context |
r.Context() |
c.Request.Context() |
c.Request().Context() |
c.Request().Ctx() |
@app.get("/string") def string(string: str): |
@Get("/string") string(@Context() ctx: Context): |
request | Request() *http.Request |
r |
c.Request() |
c.Request() |
c.Request() |
@app.get("/string") def string(string: str): |
@Get("/string") string(@Request() req: Request): |
response | Response() http.ResponseWriter |
w http.ResponseWriter |
c.Writer |
c.Response().Writer |
c.Response().BodyWriter() |
@app.get("/string") def string(string: str): |
@Get("/string") string(@Response() res: Response): |
status | Status(int) int |
w.WriteHeader(int) |
c.Writer.WriteHeader(int) |
c.Writer.WriteHeader(int) |
c.Response().SetStatusCode(int) |
@app.get("/string") def string(string: str): |
@Get("/string") string(@Status() status: Status): |
JSON | JSON(int, interface{}) |
json.NewEncoder(w).Encode() |
c.JSON(int, interface{}) |
c.JSON(int, interface{}) |
c.JSON(int, interface{}) |
@app.get("/string") def string(string: str): |
@Get("/string") string(@JSON() json: JSON): |
HTML | HTML(int, string, interface{}) |
template.Execute(w, data) |
c.HTML(int, string, interface{}) |
c.HTML(int, string, interface{}) |
c.HTML(int, string, interface{}) |
@app.get("/string") def string(string: str): |
@Get("/string") string(@HTML() html: HTML): |
text | Text(int, string) |
w.Write([]byte(string)) |
c.String(int, string) |
c.String(int, string) |
c.WriteString(string) |
@app.get("/string") def string(string: str): |
@Get("/string") string(@Text() text: Text): |
bytes | Bytes(int, []byte) |
w.Write([]byte(string)) |
c.Data(int, string, []byte) |
c.Data(int, string, []byte) |
c.Write([]byte(string)) |
@app.get("/string") def string(string: str): |
@Get("/string") string(@Bytes() bytes: Bytes): |
stream | Stream(int, string, io.Reader) |
io.Copy(w, io.Reader) |
c.Stream(int, string, io.Reader) |
c.Stream(int, string, io.Reader) |
c.Stream(int, string, io.Reader) |
@app.get("/string") def string(string: str): |
@Get("/string") string(@Stream() stream: Stream): |
file | File(string) |
http.ServeFile(w, r, string) |
c.File(string) |
c.File(string) |
c.File(string) |
@app.get("/string") def string(string: str): |
@Get("/string") string(@File() file: File): |
redirect | Redirect(int, string) |
http.Redirect(w, r, string, int) |
c.Redirect(int, string) |
c.Redirect(int, string) |
c.Redirect(int, string) |
@app.get("/string") def string(string: str): |
@Get("/string") string(@Redirect() redirect: Redirect): |
error | Error(int, error) |
http.Error(w, err.Error(), int) |
c.Error(err) |
c.Error(err) |
c.Error(err) |
@app.get("/string") def string(string: str): |
@Get("/string") string(@Error() error: Error): |
group | Group(string, func()) |
mux.NewRouter().PathPrefix(string).Subrouter() |
c.Group(string, func()) |
c.Group(string, func()) |
c.Group(string, func()) |
@app.get("/string") def string(string: str): |
@Get("/string") string(@Group() group: Group): |
middleware | Use(func()) |
mux.NewRouter().Use(func()) |
c.Use(func()) |
c.Use(func()) |
c.Use(func()) |
@app.get("/string") def string(string: str): |
@Get("/string") string(@Use() use: Use): |
static | Static(string, string) |
mux.NewRouter().PathPrefix(string).Handler(http.StripPrefix(string, http.FileServer(http.Dir(string)))) |
c.Static(string, string) |
c.Static(string, string) |
c.Static(string, string) |
@app.get("/string") def string(string: str): |
@Get("/string") string(@Static() static: Static): |
websocket | Websocket(string, func()) |
mux.NewRouter().PathPrefix(string).Handler(http.StripPrefix(string, http.FileServer(http.Dir(string)))) |
c.Websocket(string, func()) |
c.Websocket(string, func()) |
c.Websocket(string, func()) |
@app.get("/string") def string(string: str): |
@Get("/string") string(@Websocket() websocket: Websocket): |
group | Group(string, func()) |
mux.NewRouter().PathPrefix(string).Subrouter() |
c.Group(string, func()) |
c.Group(string, func()) |
c.Group(string, func()) |
@app.get("/string") def string(string: str): |
@Get("/string") string(@Group() group: Group): |