rudo
rudo
CDCloudflare Developers
Created by rudo on 9/9/2024 in #🦀rust-on-workers
worker version is latest, http feature
Yeah, I use query_pairs in the end. Thanks a lot 🙂
15 replies
CDCloudflare Developers
Created by rudo on 9/9/2024 in #🦀rust-on-workers
worker version is latest, http feature
ok, here is the lib.rs
use worker::*;

#[event(fetch)]
async fn fetch(
req: Request,
env: Env,
ctx: Context,
) -> Result<Response> {
console_error_panic_hook::set_once();
let router = Router::new();

router
.get_async("/", |req, ctx| async move {
use url::Url;
let key = req.url()?;
return if let Some(key) = key.param("num") {
Response::ok(key)
} else {
Response::error("Bad Request", 400)
}

})
.run(req, env)
.await
}
use worker::*;

#[event(fetch)]
async fn fetch(
req: Request,
env: Env,
ctx: Context,
) -> Result<Response> {
console_error_panic_hook::set_once();
let router = Router::new();

router
.get_async("/", |req, ctx| async move {
use url::Url;
let key = req.url()?;
return if let Some(key) = key.param("num") {
Response::ok(key)
} else {
Response::error("Bad Request", 400)
}

})
.run(req, env)
.await
}
15 replies
CDCloudflare Developers
Created by rudo on 9/9/2024 in #🦀rust-on-workers
worker version is latest, http feature
15 replies