Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve flexibility of handlers #2858

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Conversation

hlbarber
Copy link
Contributor

Motivation and Context

Currently handlers are constrained to OperationShape::Input to Result<OperationShape::Output, OperationShape::Error>. This is overly prescriptive. As long as handler accepts, and returns types which serialize in compliance with the input, output, and error in the Smithy model then we are in compliance with the specification.

This enables:

  • The dual of extractors, co-extractors, which insert data local to the handler into the http::Response.
  • Differing input/output representations for differing situations.

The change to FromRequest<Ser, Op, B> and IntoResponse<Ser, Op> provides adherence to #2407, paving the way for reusable types.

Description

  • Remove OperationShape::Input, OperationShape::Output, OperationShape::Error.
  • Change FromRequest<Protocol, B> to FromRequest<Ser, Op, B>.
  • Change IntoResponse<Protocol> to IntoResponse<Ser, Op>.
  • Accept handlers with arguments FromRequest<Ser, Op, B> and return types IntoResponse<Ser, Op>.
  • Introduce struct FixInput and trait FixedService as tools to remove the degree of freedom on UpgradePlugin.

@hlbarber hlbarber added ergonomics breaking-change This will require a breaking change server Rust server SDK labels Jul 19, 2023
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change This will require a breaking change ergonomics server Rust server SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants