A simple HTTP web framework for Pony, inspired by Jennet and powered by Stallion.
hobby is beta quality software that will change frequently. Expect breaking changes. That said, you should feel comfortable using it in your projects.
- Install corral
corral add github.com/ponylang/hobby.git --version 0.2.1corral fetchto fetch your dependenciesuse "hobby"to include this packagecorral run -- ponycto compile your application
use hobby = "hobby"
use stallion = "stallion"
use lori = "lori"
actor Main
new create(env: Env) =>
let auth = lori.TCPListenAuth(env.root)
hobby.Application
.>get("/", HelloHandler)
.>get("/greet/:name", GreetHandler)
.serve(auth, stallion.ServerConfig("localhost", "8080"), env.out)
primitive HelloHandler is hobby.Handler
fun apply(ctx: hobby.Context ref) =>
ctx.respond(stallion.StatusOK, "Hello!")
class val GreetHandler is hobby.Handler
fun apply(ctx: hobby.Context ref) ? =>
ctx.respond(stallion.StatusOK, "Hello, " + ctx.param("name")? + "!")See the examples directory for more, including middleware usage. For a detailed walkthrough, read the Writing Middleware guide.