Compare commits

..

No commits in common. "ef084f3dbafec4d4b14572d98f3d82fbd12611fc" and "ba8d256143a7bb76e7ee7ef7a5e578cb5ca4212b" have entirely different histories.

View file

@ -12,8 +12,6 @@ pub fn handle_request(req: Request) -> Response {
case wisp.path_segments(req) {
[] -> home_page(req)
["random"] -> handle_random()
[hash, "previous"] -> handle_previous(hash)
[hash, "next"] -> handle_next(hash)
@ -57,21 +55,6 @@ fn handle_next(hash) {
}
}
fn handle_random() {
let db_path = "members.db"
use conn <- sqlight.with_connection(db_path)
let random =
sqlight.query(
"select next from ring order by random() limit 1",
on: conn,
expecting: dynamic.decode1(Row, dynamic.element(0, dynamic.string)),
)
case random {
Ok([Row(random_link)]) -> wisp.redirect(random_link)
_ -> wisp.not_found()
}
}
fn home_page(req: Request) -> Response {
// The home page can only be accessed via GET requests, so this middleware is
// used to return a 405: Method Not Allowed response for all other methods.