46 lines
1 KiB
Gleam
46 lines
1 KiB
Gleam
import wisp.{type Request, type Response}
|
|
import gleam/http.{Get}
|
|
import bowie/web.{type Context}
|
|
import sqlight
|
|
import bowie/templates/signup
|
|
import gleam/option.{None, Some}
|
|
|
|
pub fn handle_request(req: Request, context: Context) -> Response {
|
|
use req <- web.middleware(req)
|
|
|
|
case wisp.path_segments(req) {
|
|
["signup"] ->
|
|
case req.method {
|
|
http.Get -> get_signup(req, context)
|
|
http.Post -> post_signup(req)
|
|
_ -> wisp.method_not_allowed(allowed: [http.Get, http.Post])
|
|
}
|
|
|
|
["payment_success", receipt] -> payment_success(req, receipt)
|
|
|
|
_ -> wisp.not_found()
|
|
}
|
|
}
|
|
|
|
fn get_signup(req, context: Context) {
|
|
use <- wisp.require_method(req, Get)
|
|
|
|
wisp.ok()
|
|
|> wisp.html_body(signup.render(
|
|
monthly_link: Some(context.env.monthly_link),
|
|
annual_link: Some(context.env.annual_link),
|
|
invitation: None,
|
|
))
|
|
}
|
|
|
|
fn post_signup(req) {
|
|
use <- wisp.require_method(req, http.Post)
|
|
|
|
wisp.ok()
|
|
}
|
|
|
|
fn payment_success(req, receipt) {
|
|
use <- wisp.require_method(req, http.Post)
|
|
|
|
wisp.ok()
|
|
}
|