-
-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
The one downside I see to this implementation is that it's essentially a whitelist of plaintext formats. Anything plaintext that isn't in the list and doesn't start with text/ will still be base64-encoded. So this is a general improvement in behavior, but not a complete solution.
Something to add for completeness' sake would be some way of registering nonstandard plaintext mime types. I think the best solution would be a refactor to require consumers to create an instance of WarpHandler, which would have a couple of extra methods defined on it:
(Left out definition of Svc for a little bit of brevity)
pub struct WarpHandler<Svc> {
service: Svc,
plaintext_mimes: HashSet<Mime>,
}
impl<Svc> WarpHandler<Svc> {
// Creates a WarpHandler with default mime types
pub fn new(service: Svc) -> Self { ... }
// Adds the mime to `self.plaintext_mimes`
pub fn register_plaintext_mime(&mut self, m: Mime) { ... }
// Replaces the top-level `run()` function
pub async fn run(&self) -> Result<(), WarpHandlerError> { ... }
// Replaces top-level warpp_body_as_lambda_body
fn warp_body_as_lambda_body(warp_body: WarpBody, parts: &Parts) -> Result<LambdaBody, Error> { ... }
}Originally posted by @Shadow53 in #5 (comment)
Metadata
Metadata
Assignees
Labels
No labels