pass on http request

This commit is contained in:
Shautvast 2025-11-03 19:17:34 +01:00
parent ad9e9d8888
commit b95097834f
2 changed files with 13 additions and 10 deletions

View file

@ -53,18 +53,18 @@ async fn handle_any(
let method = req.method().to_string().to_ascii_lowercase();
let uri = req.uri();
// Parse query parameters
let query_params: HashMap<String, String> = uri
.query()
.map(|q| {
url::form_urlencoded::parse(q.as_bytes())
.into_owned()
.collect()
})
.unwrap_or_default();
// // todo value = Vec<String>
// let query_params: HashMap<String, String> = uri
// .query()
// .map(|q| {
// url::form_urlencoded::parse(q.as_bytes())
// .into_owned()
// .collect()
// })
// .unwrap_or_default();
let component = format!("{}/web.{}", &uri.path()[1..], method);
Ok(Json(
interpret_async(&state.registry, &component)
interpret_async(&state.registry, &component, req)
.await
.unwrap()
.to_string(),

View file

@ -4,6 +4,7 @@ use crate::errors::{RuntimeError, ValueError};
use crate::tokens::TokenType;
use crate::value::Value;
use std::collections::HashMap;
use axum::extract::Request;
use tracing::debug;
pub struct Vm<'a> {
@ -33,7 +34,9 @@ pub fn interpret(registry: &HashMap<String, Chunk>, function: &str) -> Result<Va
pub async fn interpret_async(
registry: &HashMap<String, Chunk>,
function: &str,
_request: Request,
) -> Result<Value, RuntimeError> {
//TODO convert request to arguments
let chunk = registry.get(function);
if let Some(chunk) = chunk {
let mut vm = Vm {