smithy-lang / smithy-rs

Code generation for the AWS SDK for Rust, as well as server and generic smithy client generation.
Apache License 2.0
467 stars 183 forks source link

Code-generate `const` `Mime` values for each expected `Content-Type` in a request #3703

Open david-perez opened 1 week ago

david-perez commented 1 week ago

Currently, we re-parse expected request Content-Type header values into mime::Mimes every time we service a request. It'd be more efficient if aws_smithy_http_server::protocol::content_type_header_classifier_smithy took in directly a const Mime type.

Note that we already do this to check the Accept header (against the Content-Type of the response): https://github.com/smithy-lang/smithy-rs/blob/e912cf5e8e4d976c408d5b2c78b1d92320090ada/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpBoundProtocolGenerator.kt#L243-L261

It's probably better if we decide on https://github.com/smithy-lang/smithy-rs/issues/2666 before tackling this issue, to avoid throwaway work.

Originally source of this issue is https://github.com/smithy-lang/smithy-rs/pull/3690#discussion_r1638330220.