I’m excited to announce Oxygen.jl, a micro-framework built on top of the HTTP.jl library that’s designed to simplify building web applications in Julia. Full disclosure, the design of the API itself takes heavy inspiration from the FastApi python library
using Oxygen
using HTTP
@get "/greet" function(req::HTTP.Request)
return "hello world!"
end
# both path parameters are automatically converted to Float64's
@get "/multiply/{a}/{b}" function(req, a::Float64, b::Float64)
return a * b
end
# all objects are automatically deserialized into JSON
@get "/getdata" function()
return Dict("message" => "hello!")
end
# mount all nested files inside the "content" folder under "/static"
@staticfiles "content" "static"
# start the web server
serve()
Features
- Straightforward routing (
@get
,@post
,@put
,@patch
,@delete
and@route
macros) - Out-of-the-box JSON serialization & deserialization
- Optional type definition support for Path parameters
- Helper functions to parse & transform the body of requests & responses
- Hosting static files
- Built-in multithreading support
In the future, it may not always depend on HTTP.jl. I have some ambitious ideas which may include replacing HTTP.jl with something akin to Starlette in julia. But for the time being, I’m focusing more on practical and developer-focused features to add to the framework
Coming soon: I’m currently working on adding automatic doc generation (openapi 3.0 format)
Why build another web framework?
That’s a great question, why create another package if Julia already has full stack frameworks like Genie.jl that can do just about anything?
My quick answer: most people don’t need all features that come with these heavyweight packages. About a month ago, I was one of those people looking to quickly spin up a web server to prototype some ideas.
I wanted something lightweight and straightforward, and I didn’t want to spend a lot of time learning a new syntax. Ideally, I wanted something similar to Flask or FastApi but in Julia.
So, I set out to create this package and design a no-nonsense api that would hopefully feel familiar to JS and Python programmers and drive greater adoption in these communities.
Feature Requests
If you have any ideas or feature requests, please feel free to open an issue on the github page or startup a thread in the discussion section!