Coder Social home page Coder Social logo

Comments (1)

dnsge avatar dnsge commented on July 26, 2024

For your first question:

I can see the use for passing the raw HTTP request. How do you envision this feature? Like modifying every handler signature to pass the raw Request object too? e.g. HandleChannelUpdate func(req *http.Request, h *esb.ResponseHeaders, event *esb.EventChannelUpdate)

Or were you thinking adding some general handler OnRequest(req *http.Request) to the SubHandler? This second case could probably be implemented by wrapping the SubHandler as it implements http.Handler. Going with the first option of adding a function parameter to every handler would be a breaking change, and so if I were to make that I may also redesign some bits of the library that I'm unhappy with.

For your second question:

As for passing the request context (I assume you mean the context returned from r.Context()) to the handler functions, for example HandleChannelUpdate func(ctx context.Context, h *esb.ResponseHeaders, event *esb.EventChannelUpdate), I'm not sure. It feels a bit like an anti-pattern to pass the context of a request that is about to finish to an asynchronous event handler.

However, there is context.Context.WithoutCancel, which could be used to just copy the values in the context detached from the deadline associated with the request. If you just need the key-values in the context, you could probably construct an empty context at the start of the handler, populate it, and pass it on. I'm hesitant about making these handlers take a ton of arguments.

from twitch-eventsub-framework.

Related Issues (5)

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.