You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to setup an API inside a module, it turns out that the handlers are not being registered. I have to define them outside the module to make it work.
Minimal example
Define inside a module
module BuildMyAPI
using Oxygen
functionbuild_api(app=instance())
app.get("/") doreturn"Hello World"endreturn app
endendusing.BuildMyAPI: build_api
app =build_api()
# The route is not registered
app.serve(port=8010, async=true)
Define outside a module
using Oxygen
app =instance()
app.get("/") doreturn"Hello World"end# This works
app.serve(port=8010, async=true)
The text was updated successfully, but these errors were encountered:
Thanks for the code snippet, I'll have to take a look into that. In the meantime, I'd recommend using @oxidise macro to do the same for now (as long as the number of servers remains static).
The instance function has always been a bit hacky since it's dynamically creating a module at runtime in Julia which isn't encouraged (but still possible).
When I try to setup an API inside a module, it turns out that the handlers are not being registered. I have to define them outside the module to make it work.
Minimal example
Define inside a module
Define outside a module
The text was updated successfully, but these errors were encountered: