Comments (2)
I've been wracking my brains for ways to wrap cowboy_router:compile
or the cowboy_router
middleware, or to wrap the individual handlers, but I can't come up with anything that doesn't feel like a hack.
from cowboy.
After some thought, I've come up with the following, which doesn't require any cowboy changes:
- Replace the current
Handler
with a tuple,{Handler, HandlerOpts}
- Replace the current
HandlerOpts
withHandlerMetadata
.
Add a middleware that goes in between cowboy_router
and cowboy_handler
that does this:
execute(Req, Env = #{handler := {Handler, HandlerOpts}, handler_opts := Metadata}) ->
Env2 = Env#{handler => Handler, handler_opts => HandlerOpts, handler_metadata => Metadata},
{ok, Req, Env2}.
Getting handler_metadata
into user_data
where the metrics callback can see it is left as an exercise for the reader.
from cowboy.
Related Issues (20)
- Reject responses that have explicit set-cookie HOT 7
- gunsmoke = gun + cowboy + tls + websocket HOT 3
- when use cowboy:start_tls can not connect HOT 7
- cowboy_clear's protocols option
- Document range requests in cowboy_rest and cowboy_static HOT 1
- 2.10 Getting Started: Makefile issue -- No rule to make target 'run' HOT 2
- Rewrite ws_autobahn to no longer use autobahn-testsuite HOT 2
- I want to use Cowboy 2.11's Websocket over HTTP/2 feature, How do I configure nginx HOT 2
- Apply routing constraint to […] bind? HOT 3
- Is cowboy affected by CVE-2023-46118 ? HOT 1
- Cookie Flexiblity HOT 2
- Response cookies must be set using cowboy_req HOT 1
- content_types_provided should be allowed to return the empty list when no Accept header is specified HOT 6
- HTTP/2: to many stream window size updates after connection window size update HOT 3
- Use async cancel_timer where applicable HOT 1
- which erlang version is supported? HOT 1
- Fix introduction supported OTP versions
- Add `licenses` to `.app` for `rebar3_sbom` HOT 11
- Is there a graceful way to drain a keep-alive connection server side? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cowboy.