Wisp

A practical web framework for Gleam

OK, but what does Wisp actually give you?

And a recommended project structure, so you can focus on solving the problems you want to solve, rather than reinventing the wheel.

That sounds good! What does it look like?

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.