Implement closed typed effect path
This commit is contained in:
+13
-23
@@ -26,12 +26,10 @@ pub const fn runtime_js() -> RuntimeJs {
|
||||
RuntimeJs
|
||||
}
|
||||
|
||||
// req: axum_integration/005
|
||||
pub const fn runtime_js_hash() -> &'static str {
|
||||
hemx_js::RUNTIME_JS_HASH
|
||||
}
|
||||
|
||||
// req: axum_integration/005
|
||||
pub const fn runtime_js_path() -> &'static str {
|
||||
hemx_js::RUNTIME_JS_PATH
|
||||
}
|
||||
@@ -354,7 +352,6 @@ impl InteractionForm {
|
||||
Self::from_parts(parse_urlencoded_pairs(body)?, Vec::new())
|
||||
}
|
||||
|
||||
// req: multipart/001, req: multipart/002
|
||||
pub async fn parse_multipart(
|
||||
mut multipart: Multipart,
|
||||
) -> Result<Self, InteractionFormRejection> {
|
||||
@@ -471,7 +468,6 @@ pub fn state_interactions<S>(fingerprint: BuildFingerprint, state: S) -> StateHa
|
||||
where
|
||||
S: Clone + Send + Sync + 'static,
|
||||
{
|
||||
// req: axum_integration/003 req: ceremony/001
|
||||
interactions(fingerprint).with_state(state)
|
||||
}
|
||||
|
||||
@@ -1254,8 +1250,8 @@ where
|
||||
{
|
||||
type Rejection = InteractionFormRejection;
|
||||
|
||||
async fn from_request(req: Request<Body>, state: &S) -> Result<Self, Self::Rejection> {
|
||||
InteractionForm::from_request(req, state)
|
||||
async fn from_request(request: Request<Body>, state: &S) -> Result<Self, Self::Rejection> {
|
||||
InteractionForm::from_request(request, state)
|
||||
.await
|
||||
.map(|form| Self { form })
|
||||
}
|
||||
@@ -1267,16 +1263,16 @@ where
|
||||
{
|
||||
type Rejection = InteractionFormRejection;
|
||||
|
||||
async fn from_request(req: Request<Body>, state: &S) -> Result<Self, Self::Rejection> {
|
||||
match interaction_media_type(req.headers())? {
|
||||
async fn from_request(request: Request<Body>, state: &S) -> Result<Self, Self::Rejection> {
|
||||
match interaction_media_type(request.headers())? {
|
||||
InteractionMediaType::Multipart => {
|
||||
let multipart = Multipart::from_request(req, state)
|
||||
let multipart = Multipart::from_request(request, state)
|
||||
.await
|
||||
.map_err(extractor_rejection)?;
|
||||
Self::parse_multipart(multipart).await
|
||||
}
|
||||
InteractionMediaType::UrlEncoded => {
|
||||
let bytes = Bytes::from_request(req, state)
|
||||
let bytes = Bytes::from_request(request, state)
|
||||
.await
|
||||
.map_err(extractor_rejection)?;
|
||||
Self::parse_urlencoded(&bytes)
|
||||
@@ -1459,7 +1455,6 @@ pub fn runtime_js_route_path() -> &'static str {
|
||||
runtime_js_path()
|
||||
}
|
||||
|
||||
// req: push/001, req: push/003, req: push/004
|
||||
pub fn sse<S, E>(batches: S) -> Sse<impl Stream<Item = Result<Event, E>> + Send>
|
||||
where
|
||||
S: Stream<Item = Result<EffectBatch, E>> + Send + 'static,
|
||||
@@ -1481,14 +1476,14 @@ pub fn encode_sse_batch(batch: &EffectBatch) -> String {
|
||||
fn base64_url_no_pad(input: &[u8]) -> String {
|
||||
const ALPHABET: &[u8; 64] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
||||
let mut out = String::with_capacity((input.len() * 4).div_ceil(3));
|
||||
let mut chunks = input.chunks_exact(3);
|
||||
for chunk in &mut chunks {
|
||||
out.push(ALPHABET[(chunk[0] >> 2) as usize] as char);
|
||||
out.push(ALPHABET[(((chunk[0] & 0x03) << 4) + (chunk[1] >> 4)) as usize] as char);
|
||||
out.push(ALPHABET[(((chunk[1] & 0x0f) << 2) + (chunk[2] >> 6)) as usize] as char);
|
||||
out.push(ALPHABET[(chunk[2] & 0x3f) as usize] as char);
|
||||
let (chunks, remainder) = input.as_chunks::<3>();
|
||||
for [a, b, c] in chunks {
|
||||
out.push(ALPHABET[(a >> 2) as usize] as char);
|
||||
out.push(ALPHABET[(((a & 0x03) << 4) + (b >> 4)) as usize] as char);
|
||||
out.push(ALPHABET[(((b & 0x0f) << 2) + (c >> 6)) as usize] as char);
|
||||
out.push(ALPHABET[(c & 0x3f) as usize] as char);
|
||||
}
|
||||
match chunks.remainder() {
|
||||
match remainder {
|
||||
[a] => {
|
||||
out.push(ALPHABET[(a >> 2) as usize] as char);
|
||||
out.push(ALPHABET[((a & 0x03) << 4) as usize] as char);
|
||||
@@ -1577,7 +1572,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn root_fingerprint_is_added_to_initial_root() {
|
||||
// req: test/005
|
||||
let html = html_with_root_fingerprint(
|
||||
"<html><body><main data-hemx-root>Docs</main></body></html>".into(),
|
||||
BuildFingerprint(99),
|
||||
@@ -1594,7 +1588,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn existing_root_fingerprint_is_preserved() {
|
||||
// req: test/005
|
||||
let html = html_with_root_fingerprint(
|
||||
"<main data-hemx-root data-hemx-fp=\"1\">Docs</main>".into(),
|
||||
BuildFingerprint(99),
|
||||
@@ -1618,7 +1611,6 @@ mod tests {
|
||||
html_with_root_fingerprint(html.clone(), BuildFingerprint(99)),
|
||||
html
|
||||
);
|
||||
// test req: abi/005
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1639,7 +1631,6 @@ mod tests {
|
||||
] {
|
||||
assert_eq!(base64_url_no_pad(input), expected);
|
||||
}
|
||||
// req: push/008 test
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1677,7 +1668,6 @@ mod tests {
|
||||
InteractionForm::parse_urlencoded(b"__h=1&bad=%"),
|
||||
Err(InteractionFormRejection::InvalidBody)
|
||||
);
|
||||
// test req: form/002 req: failure/003
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
Reference in New Issue
Block a user