4 ms·
Hi there, I just wanted to chime in and let you know that you don't have to define the request handler in the same place as the path. You can import handlers fr
by ndortega 4y ago
Hi there, I just wanted to chime in and let you know that you don't have to define the request handler in the same place as the path. You can import handlers from other modules and just pass them to one of the routing macros. The reason why you see that pattern so often in the docs is that I wanted to keep the examples as simple as possible
Oxygen.jl supports several different design styles and leaves the choice up to the developer.
- Central file with routes & import request handlers from other modules
- Define routes & handlers across multiple modules and just call serve() from the main module
Below is a quick example of how you could separate your application logic from any routing logic
------- B.jl -------
module B
export greet
function greet()
"hello world!"
end
end
------- main.jl -------
module Main
using Oxygen
include("B.jl"); using .B
@get "/hello" greet
serve()
end