diff options
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 17 |
1 files changed, 1 insertions, 16 deletions
@@ -5,7 +5,6 @@ #![allow(internal_features)] #![allow(mutable_transmutes)] use maud::{html, Markup, PreEscaped, DOCTYPE}; -use std::mem::{take, transmute}; use worker::*; pub mod dateparse; @@ -15,20 +14,6 @@ use crate::{ solar::{dow, solar}, }; -async fn text(r: &mut Response) -> Result<String> { - match r.body() { - ResponseBody::Body(bytes) => unsafe { - let bytes: &mut Vec<u8> = transmute(bytes); - Ok(String::from_utf8_unchecked(take(bytes))) - }, - ResponseBody::Empty => Ok(String::new()), - ResponseBody::Stream(_) => unsafe { - let bytes = r.bytes().await?; - Ok(String::from_utf8_unchecked(bytes)) - }, - } -} - #[event(fetch)] async fn fetch(req: Request, env: Env, _ctx: Context) -> Result<Response> { Router::new() @@ -36,7 +21,7 @@ async fn fetch(req: Request, env: Env, _ctx: Context) -> Result<Response> { let u = req.url()?; let a = ctx.env.assets("ASSETS")?; let mut a = a.fetch(u.join("_/diary")?, None).await?; - let a = text(&mut a).await?; + let a = unsafe { String::from_utf8_unchecked(a.bytes().await?) }; bone("shitpit", "look in the sky! it's a bird! it's a plane! no it's superego!", html! { p { "The numbering system for people (#1, #2, ...) is arbitrary and " |
