Bonsai.jl: A HTTP framework

Hi I’m developing a new HTTP framework called Bonsai.jl. It’s still WIP but should be useable enough for a package annoncement. A short snippet of what the code looks like.

using Bonsai

const app = App()

function index(stream::HTTP.Stream)
    query = Bonsai.read( stream, Query(name=Union{String, Nothing}))
    name = isnothing(query.name) ? "John Doe" : query.name  
    Bonsai.write(stream, Body("Hi, $name"))
end

function register_handlers!(app)
    app.get["/"] = index
end

function run()
    register_handlers!(app)
    start(app, port=9091)
end

It basically provides abstraction over a HTTP.Stream which allows you to declaratively read and write data by specifying types. Feedback, issues and pulls would be appericate, thanks!

6 Likes