Replies: 1 comment 7 replies
-
@HiperMaximus @jiachengzhang1 |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone,
I'd like to get some feedback on my latest PR which makes Oxygen compatible with HTTP.jl v1.0.0+. Upgrading the package forced me to make some changes to the internal API which brought in a couple of features like chaining middleware functions.
Middleware functions make it easy to create workflows to intercept all incoming requests and outgoing responses. Let's say you have a more complex web application, you'll probably need to add most of the following features:
Instead of copying and pasting the same code throughout all your routes, you could create middleware functions for each of these and call them in one place to have all requests & responses pass through them.
So now that we see why this might be helpful I wanted to get your input on the syntax of chaning these middleware functions
The
serve()
andserveparallel()
functions have booth been updated to accept middleware functions like this:serve(handler1, handler2, handler3)
In this example they would get executed in the order they were passed (handler1, handler2, and handler3). It's worth remembering you can still pass the same keywords as before, you just need to add in a semicolon to separate the middleware functions from the rest:
Questions for you:
Below is a simplified example of what it would look like in action:
Beta Was this translation helpful? Give feedback.
All reactions