A practical web framework for Gleam
Wisp is simple, type safe, and entirely free from confusing magic. Make development as stress-free as possible whether you're starting a new prototype or maintaining a large system.
Thanks to the Mist HTTP server and the mighty multithreaded BEAM runtime Wisp applications are fast, even at the 99th percentile during a big burst of traffic. In benchmarks Wisp can outperform Go, NodeJS, and Elixir Phoenix + Cowboy.
If your application matters then you're going to want to test it. A Wisp web application is as easy to test as any regular Gleam function, and an assortment of useful test helpers are provided to keep your tests concise.
Scrambling to fix problems in production is stressful, so Wisp uses Gleam's type safety and the BEAM's fault tolerance help prevent those panicked late night phone calls from your boss.
And a recommended project structure, so you can focus on solving the problems you want to solve, rather than reinventing the wheel.
Here's a JSON API request handler that saves an item in a database.
import my_app/people
import my_app/web.{Context}
import gleam/result.{try}
import wisp.{Request, Response}
pub fn handle_request(req: Request, ctx: Context) -> Response {
use json <- wisp.require_json(req)
let result = {
use params <- try(people.parse_params(json))
use person <- try(people.save(params, ctx.db))
Ok(people.to_json(person))
}
case result {
Ok(body) -> wisp.json_response(body, 201)
Error(_) -> wisp.bad_request()
}
}
Want to learn more? Check out the Wisp guides.