pass on http request
This commit is contained in:
parent
ad9e9d8888
commit
b95097834f
2 changed files with 13 additions and 10 deletions
20
src/main.rs
20
src/main.rs
|
|
@ -53,18 +53,18 @@ async fn handle_any(
|
||||||
let method = req.method().to_string().to_ascii_lowercase();
|
let method = req.method().to_string().to_ascii_lowercase();
|
||||||
let uri = req.uri();
|
let uri = req.uri();
|
||||||
|
|
||||||
// Parse query parameters
|
// // todo value = Vec<String>
|
||||||
let query_params: HashMap<String, String> = uri
|
// let query_params: HashMap<String, String> = uri
|
||||||
.query()
|
// .query()
|
||||||
.map(|q| {
|
// .map(|q| {
|
||||||
url::form_urlencoded::parse(q.as_bytes())
|
// url::form_urlencoded::parse(q.as_bytes())
|
||||||
.into_owned()
|
// .into_owned()
|
||||||
.collect()
|
// .collect()
|
||||||
})
|
// })
|
||||||
.unwrap_or_default();
|
// .unwrap_or_default();
|
||||||
let component = format!("{}/web.{}", &uri.path()[1..], method);
|
let component = format!("{}/web.{}", &uri.path()[1..], method);
|
||||||
Ok(Json(
|
Ok(Json(
|
||||||
interpret_async(&state.registry, &component)
|
interpret_async(&state.registry, &component, req)
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_string(),
|
.to_string(),
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ use crate::errors::{RuntimeError, ValueError};
|
||||||
use crate::tokens::TokenType;
|
use crate::tokens::TokenType;
|
||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use axum::extract::Request;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
pub struct Vm<'a> {
|
pub struct Vm<'a> {
|
||||||
|
|
@ -33,7 +34,9 @@ pub fn interpret(registry: &HashMap<String, Chunk>, function: &str) -> Result<Va
|
||||||
pub async fn interpret_async(
|
pub async fn interpret_async(
|
||||||
registry: &HashMap<String, Chunk>,
|
registry: &HashMap<String, Chunk>,
|
||||||
function: &str,
|
function: &str,
|
||||||
|
_request: Request,
|
||||||
) -> Result<Value, RuntimeError> {
|
) -> Result<Value, RuntimeError> {
|
||||||
|
//TODO convert request to arguments
|
||||||
let chunk = registry.get(function);
|
let chunk = registry.get(function);
|
||||||
if let Some(chunk) = chunk {
|
if let Some(chunk) = chunk {
|
||||||
let mut vm = Vm {
|
let mut vm = Vm {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue