Skip to content
This repository was archived by the owner on Mar 14, 2026. It is now read-only.

Latest commit

 

History

History
55 lines (41 loc) · 1.22 KB

File metadata and controls

55 lines (41 loc) · 1.22 KB

Morsel

Build Status

Morsel is a Sinatra-like micro framework for declaring routes and handling requests. It is built on top of HttpServer.jl and Meddle.jl.

Installation: Pkg.add("Morsel")

Example

Here is a brief example that will return a few different messages for different routes, if you run this and open localhost:8000 you will see "This is the root" for GET, POST or PUT requests. The line get(app, "/about") do ... is shorthand for only serving GET requests through that route.

using Morsel

app = Morsel.app()

route(app, GET | POST | PUT, "/") do req, res
    "This is the root"
end

get(app, "/about") do req, res
    "This app is running on Morsel"
end

start(app, 8000)

The wsroute function can be used to set up a route that opens a WebSocket connection.

wsroute(app, GET, "/echo") do req, sock
    while true
        msg = bytestring(read(sock))
        write(sock, msg)
    end
end

:::::::::::::
::         ::
:: Made at ::
::         ::
:::::::::::::
     ::
Hacker School
:::::::::::::