hand

finger proxy server
Log | Files | Refs | README

commit c03a7157d7e85cad4cf0b5e8b9899b53e221fcde
parent dd93de1ccb6848aad983d7e0c95ca71ae4293d33
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Fri,  3 Dec 2021 18:20:02 -0800

Add URL queries

Diffstat:
Msrc/main.rs | 19++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -4,6 +4,7 @@ use vial::prelude::*; routes! { GET "/" => index; + GET "/*query" => index; POST "/" => post; } @@ -46,21 +47,29 @@ pre { </head> <body> <main> -<h1>👐finger.flounder.online👐</h1> -<form method='POST'> +<h1>👐flounder finger proxy👐</h1> +<form method='POST' action='/'> 👉<input type='text' placeholder='e.g. alex@flounder.online' name='query'/> <input type='submit'/> </form>"#; -fn index(req: Request) -> &'static str { +fn index(req: Request) -> String { // TODO if path != /, interpret as url - form + let query = req.arg("query"); + if let Some(q) = query { + return render_finger(q); + } + form.to_owned() } // TODO: add permalink // TODO: url parameters -fn post(req: Request) -> String { +fn post(req: Request) -> Response { let query = req.form("query").unwrap_or(""); + Response::redirect_to(format!("/{}", query)) +} + +fn render_finger(query: &str) -> String { let user: &str; let host: &str; let params: Vec<&str> = query.split("@").collect();