add "random" endpoint that just redirects you to a random node. #1
1 changed files with 3 additions and 3 deletions
|
@ -60,14 +60,14 @@ fn handle_next(hash) {
|
|||
fn handle_random() {
|
||||
let db_path = "members.db"
|
||||
use conn <- sqlight.with_connection(db_path)
|
||||
let next =
|
||||
let random =
|
||||
nebkor marked this conversation as resolved
Outdated
|
||||
sqlight.query(
|
||||
"select next from ring order by random() limit 1",
|
||||
on: conn,
|
||||
expecting: dynamic.decode1(Row, dynamic.element(0, dynamic.string)),
|
||||
)
|
||||
case next {
|
||||
Ok([Row(next_link)]) -> wisp.redirect(next_link)
|
||||
case random {
|
||||
nebkor marked this conversation as resolved
Outdated
erika
commented
And here And here
|
||||
Ok([Row(random_link)]) -> wisp.redirect(random_link)
|
||||
nebkor marked this conversation as resolved
Outdated
erika
commented
and here and here
|
||||
_ -> wisp.not_found()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue
can we rename
next
torandom
?