#[event(fetch)]
async fn main(mut req: Request, _env: Env, _ctx: Context) -> Result<Response> {
if req.method() == Method::Post{
if let Ok(body) = req.text().await{
match serde_json::from_str::<TVSignal>(&body) {
Ok(tvs)=> {
match Fetch::Request(tvs.request()).send().await {
Ok(_) => Response::ok("Success"),
Err(_) => Response::error("Error to send request to OKX", 502),
}
},
Err(_) => Response::error("Can't deserialize json to pass value", 400),
}
}else {
Response::error("Need text body",400)
}
}else {
Response::error("There are apis, please request with POST",400)
}
}
#[event(fetch)]
async fn main(mut req: Request, _env: Env, _ctx: Context) -> Result<Response> {
if req.method() == Method::Post{
if let Ok(body) = req.text().await{
match serde_json::from_str::<TVSignal>(&body) {
Ok(tvs)=> {
match Fetch::Request(tvs.request()).send().await {
Ok(_) => Response::ok("Success"),
Err(_) => Response::error("Error to send request to OKX", 502),
}
},
Err(_) => Response::error("Can't deserialize json to pass value", 400),
}
}else {
Response::error("Need text body",400)
}
}else {
Response::error("There are apis, please request with POST",400)
}
}