Giter Site home page Giter Site logo

Add support for fasthttp about chi HOT 2 CLOSED

go-chi avatar go-chi commented on May 5, 2024 1
Add support for fasthttp

from chi.

Comments (2)

VojtechVitek avatar VojtechVitek commented on May 5, 2024 1

@hmgle thanks for the investigation and really interesting benchmarks!

I think having fork for fasthttp would be the best option here right now, though.

We're really excited about Go 1.7's built-in context, which will allow us to simplify chi, remove interface{} args and use the standard http.Handler signatures:

func Handler(w http.ResponseWriter, r *http.Request) {
   user, ok := r.Context().Value("user")
   // do something
})

Please, check out https://github.com/pressly/chi/tree/v2 branch.


If we were to support fasthttp and its custom signatures func(ctx context.Context, fctx *fasthttp.RequestCtx), we'd have to maintain a lot more again.

Fasthttp seems to be really fast, but I wonder about missing HTTP 2 support and Go 1.7's request context.

We may have fasthttp as a chi subpkg one day. But I doubt it could happen anytime soon because of maintainability issues.

import "github.com/pressly/chi/fasthttp

func main() {
  r := chi.NewRouter()

  r.Get("/", func(ctx context.Context, fctx *fasthttp.RequestCtx) {
    w.Write([]byte("hi"))
  })

  http.ListenAndServe(":3333", r)
}

from chi.

hmgle avatar hmgle commented on May 5, 2024

@VojtechVitek I agree.
Fasthttp had the advantage of a good performance, but at the same time it is incompatible with net/http. It would not benefit from net/http standardization.

from chi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.