Commit Graph

186 Commits

Author SHA1 Message Date
Zelda Hessler 5b9d0c0fff
fix clippy lints from the future (#3438)
## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->
Because the build pipeline is checking for these.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2024-02-26 15:30:51 +00:00
John DiSanti b382ebc063
Upgrade cargo-check-external-types to 0.1.11 (#3413)
_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2024-02-21 14:28:25 +00:00
Russell Cohen 06e66d191c
Scrape doc examples (#3334)
## Motivation and Context
Extracted from #3308, this adds doc example scraping. This won't make
much of a difference yet but it will help if we're able to move example
repos directly under the SDKs themselves when appropriate.

## Description
https://doc.rust-lang.org/rustdoc/scraped-examples.html

## Testing
verified that examples appear in docs when expected

## Checklist
no changelog

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-12-20 18:11:43 +00:00
david-perez 1bb0349e5d
Update server TLS example to showcase how to extract connection information (#3023)
Showcase how to pass TLS derived information to server operation
handlers, like the certificate chain presented by the client.

To test, run `RUST_LOG=pokemon_service_tls=DEBUG cargo run` and `curl -v
--insecure https://localhost:13734/do-nothing`. Alternatively, run the
tests using `RUST_LOG=pokemon_service_tls=DEBUG cargo test`, which have
been updated to hit the operation that logs the TLS connection derived
information.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-12-19 15:53:37 +00:00
John DiSanti aa1f556ae0
Upgrade nightly used in CI (#3073)
_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Co-authored-by: ysaito1001 <awsaito@amazon.com>
2023-12-14 11:30:23 -08:00
Russell Cohen 0bcc193628 Add the `docsrs` autocfg attr to all crates
This also adds it to generated crates, and adds an autofix+lint to manage these attributes.
2023-12-08 10:24:19 -05:00
Russell Cohen 8df5ac8545
Update links (these don't redirect) (#3218)
Fix broken links as a result of repo movement

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-12-05 17:22:54 -08:00
Russell Cohen 404f402e59
Feature-gate http versions in aws-smithy-runtime-api (#3236)
## Motivation and Context
Without this, we will have http = 0.2 permanently in-tree.

## Description
- Add feature gate for http 02x. 
- ~Add http 1x as an experiment.~

## Testing
CI

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-11-17 15:00:56 -08:00
John DiSanti 7eb008c4f7
Create the HTTP `Response` wrapper types (#3148)
For the same reason that the request wrapper types were created in
#3059, this PR establishes the response wrapper types and refactors
existing code to use them.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-11-10 16:56:04 -08:00
John DiSanti 6438a09bef
Fix repo org move issues (#3166)
This PR fixes issues introduced by moving the repository from
awslabs/smithy-rs to smithy-lang/smithy-rs.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-11-10 18:51:04 +00:00
david-perez f0929e74ba
Allow server decorators to inject methods on config (#3111)
PR #3095 added a code-generated `${serviceName}Config` object on which
users can register layers and plugins. For example:

```rust
let config = PokemonServiceConfig::builder()
    .layer(layers)
    .http_plugin(authn_plugin)
    .model_plugin(authz_plugin)
    .build();
```

This PR makes it so that server decorators can inject methods on this
config builder object. These methods can apply arbitrary layers, HTTP
plugins, and/or model plugins. Moreover, the decorator can configure
whether invoking such method is required or not.

For example, a decorator can inject an `aws_auth` method that configures
some plugins using its input arguments. Missing invocation of this
method
will result in the config failing to build:

```rust
let _: SimpleServiceConfig<
    // No layers have been applied.
    tower::layer::util::Identity,
    // One HTTP plugin has been applied.
    PluginStack<IdentityPlugin, IdentityPlugin>,
    // One model plugin has been applied.
    PluginStack<IdentityPlugin, IdentityPlugin>,
> = SimpleServiceConfig::builder()
    // This method has been injected in the config builder!
    .aws_auth("a".repeat(69).to_owned(), 69)
    // The method will apply one HTTP plugin and one model plugin,
    // configuring them with the input arguments. Configuration can be
    // declared to be fallible, in which case we get a `Result` we unwrap
    // here.
    .expect("failed to configure aws_auth")
    .build()
    // Since `aws_auth` has been marked as required, if the user misses
    // invoking it, this would panic here.
    .unwrap();
```

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-10-31 16:10:09 +00:00
david-perez 53dcff3ff0
Build services with a derived configuration object (#3095)
This is a pared-down version of #2809.

This is the code-generated version of the
david-perez/smithy-rs-service-config#2 POC.

This introduces a code-generated `PokemonServiceConfig` object which is
provided to the service builder constructor via
`PokemonService::builder(config: PokemonServiceConfig)`. This will
displace the
current `builder_without_plugins` and `builder_with_plugins`,
deprecating them.
We will eventually remove them.

The motivation is to have a single place where to register plugins and
layers.
Smithy traits can leverage this object to inject methods that can apply
plugins
and layers. For example, an `@authorization` trait implementer could
vend a
smithy-rs decorator that pre-applied an authorization plugin inside the
`${serviceName}Config` object, possibly exposing a method to pass in any
runtime arguments needed to configure the middleware.

## Checklist
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-10-30 16:25:04 +00:00
ysaito1001 2a51e0bceb
Feature-gate public use of `http-body` and `hyper` within `aws-smithy-types` (#3088)
## Motivation and Context
Implements https://github.com/awslabs/smithy-rs/issues/3033

## Description
This PR hides behind cargo features the third-party types from
`http-body` and `hyper` crates that are used in`aws-smithy-types`'
public API. Customers need to opt-in by enabling a cargo feature
`http-body-0-4-x` in `aws-smithy-types` to create an `SdkBody` or
`ByteStream` using those third-party types. For more details, please see
[the upgrade
guide](https://github.com/awslabs/smithy-rs/discussions/3089).

As can been seen from code changes, to reduce the surface area where we
need to feature-gate things, we have fused the
`aws_smithy_types::body::Inner::Streaming` enum variant into
`aws_smithy_types::body::Inner::Dyn` variant, thereby removing
`SdkBody::from_dyn`.

## Testing
Relied on existing tests in CI

## Checklist
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2023-10-25 16:45:22 +00:00
ysaito1001 e447a22794
Re-point those using `BuildError` from smithy-http to smithy-types (#3070)
## Motivation and Context
Completes #3054 (a follow-up on #3032)

## Description
#3032 moved `BuildError` from `aws_smithy_http::operation::error` to
`aws_smithy_types::error::operation`. That PR also left "breadcrumbs",
so that customers could still consume `BuldError` from `aws_smithy_http`
after the move.

This PR turns breadcrumbs into deprecation messages (via
`#[deprecated(...)]`) and updates existing places that used to use moved
types from `aws_smithy_http` to `aws_smithy_types`.

## Testing
Relied on tests in CI.

## Checklist
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Co-authored-by: Russell Cohen <rcoh@amazon.com>
2023-10-19 18:38:25 +00:00
david-perez 3ab5a6926f
Showcase a minimal operation-agnostic server model plugin (#3060)
Agnostic in that it's generic over the operation it's applied to.

Figuring out how to write such a plugin can be fun but is not trivial.
I'm mostly adding this as a reference to refresh my memory the next time
I have to implement one of these.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-10-17 11:42:59 +00:00
david-perez fa54d8b6b5
Check `Content-Type` header in all server protocols (#2531)
## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-08-08 13:52:13 +00:00
david-perez e060135e01
Move `alb_health_check` module out of the `plugin` module (#2865)
The current module location is misleading, since you never want to run
the layer as a plugin: plugins always run after routing, and the health
check should be enacted before routing. Examples have been corrected,
and a test has been added.

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-07-21 13:24:08 +00:00
david-perez ddba46086a
Better distinguish model and HTTP plugins (#2827)
So far, servers have tacitly worked with the notion that plugins come in
two flavors: "HTTP plugins" and "model plugins":

- A HTTP plugin acts on the HTTP request before it is deserialized, and
  acts on the HTTP response after it is serialized.
- A model plugin acts on the modeled operation input after it is
  deserialized, and acts on the modeled operation output or the modeled
  operation error before it is serialized.

However, this notion was never reified in the type system. Thus, users
who pass in a model plugin where a HTTP plugin is expected or
viceversa in several APIs:

```rust
let pipeline = PluginPipeline::new().push(http_plugin).push(model_plugin);

let app = SimpleService::builder_with_plugins(http_plugins, IdentityPlugin)
    .post_operation(handler)
    /* ... */
    .build()
    .unwrap();
```

would get the typical Tower service compilation errors, which can get
very confusing:

```
error[E0631]: type mismatch in function arguments
  --> simple/rust-server-codegen/src/main.rs:47:6
   |
15 | fn new_svc<S, Ext>(inner: S) -> model_plugin::PostOperationService<S, Ext> {
   | -------------------------------------------------------------------------- found signature defined here
...
47 |     .post_operation(post_operation)
   |      ^^^^^^^^^^^^^^ expected due to this
   |
   = note: expected function signature `fn(Upgrade<RestJson1, (PostOperationInput, _), PostOperationService<aws_smithy_http_server::operation::IntoService<simple::operation_shape::PostOperation, _>, _>>) -> _`
              found function signature `fn(aws_smithy_http_server::operation::IntoService<simple::operation_shape::PostOperation, _>) -> _`
   = note: required for `LayerFn<fn(aws_smithy_http_server::operation::IntoService<..., ...>) -> ... {new_svc::<..., ...>}>` to implement `Layer<Upgrade<RestJson1, (PostOperationInput, _), PostOperationService<aws_smithy_http_server::operation::IntoService<simple::operation_shape::PostOperation, _>, _>>>`
   = note: the full type name has been written to '/local/home/davidpz/workplace/smithy-ws/src/SmithyRsSource/target/debug/deps/simple-6577f9f79749ceb9.long-type-4938700695428041031.txt'
```

This commit introduces the `HttpPlugin` and `ModelPlugin` marker traits,
allowing plugins to be marked as an HTTP plugin, a model plugin, or
both. It also removes the primary way of concatenating plugins,
`PluginPipeline`, in favor of `HttpPlugins` and `ModelPlugins`, which
eagerly check that whenever a plugin is `push`ed, it is of the expected
type. The generated service type in the server SDKs'
`builder_with_plugins` constructor now takes an `HttpPlugin` as its
first parameter, and a `ModelPlugin` as its second parameter.

I think this change perhaps goes counter to the generally accepted
wisdom that trait bounds in Rust should be enforced "at the latest
possible moment", that is, only when the behavior encoded in the trait
implementation is relied upon in the code (citation needed).
However, the result is that exposing the concepts of HTTP plugin and
model plugin in the type system makes for code that is easier to reason
about, and produces more helpful compiler error messages.

Documentation about the plugin system has been expanded, particularly on
how to implement model plugins.

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-07-04 12:19:15 +00:00
Harry Barber 934129cf4c
Consolidate `proto` and `protocols` modules into single `protocol` module (#2780)
## Motivation and Context

We have two modules `proto` and `protocols` in `aws_smithy_http_server`,
these can be consolidated.
2023-06-20 12:27:25 +00:00
Harry Barber b2bdcba57a
Parameterize `Plugin` by service rather than protocol (#2772)
## Motivation and Context

Closes https://github.com/awslabs/smithy-rs/issues/1839

Currently, `Plugin` is parameterized by protocol and operation. To
improve symmetry, extensibility and uniformity we switch this to be
parameterized by service instead. The protocol can still be recovered
via the `type Protocol` associated type on `ServiceShape`.

## Description

- Add `ServiceShape` trait, encoding the properties of a Smithy service.
- Change `Plugin<Protocol, Operation, S>` to `Plugin<Service, Operation,
S>`.
- Add `FilterByOperation` and `filter_by_operation` `Plugin`s.
2023-06-15 21:37:24 +00:00
Harry Barber 07bd832a21
Relax bounds on `Scoped` (#2779)
## Motivation and Context

I accidentally added this bound, it is not only redundant but its
absence is one of the key benefits of this approach.
2023-06-15 13:30:54 +00:00
Harry Barber 988eb617fb
Add `Scoped` `Plugin` (#2759)
## Motivation and Context

The
[`FilterByOperationName`](https://docs.rs/aws-smithy-http-server/0.55.4/aws_smithy_http_server/plugin/struct.FilterByOperationName.html)
allows the customer to filter application of a plugin. However this is a
_runtime_ filter. A faster and type safe alternative would be a nice
option.

## Description

Add `Scoped` `Plugin` and `scope` macro.

---------

Co-authored-by: david-perez <d@vidp.dev>
2023-06-14 14:17:35 +00:00
John DiSanti cfff41a883
Upgrade MSRV to 1.68.2 (#2745)
## Motivation and Context
This PR upgrades the MSRV to 1.68.2.

## Checklist
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Co-authored-by: Zelda Hessler <zhessler@amazon.com>
Co-authored-by: 82marbag <69267416+82marbag@users.noreply.github.com>
2023-06-13 15:23:04 +00:00
Zelda Hessler 8c4d186487
Update dependencies flagged by cargo audit (#2753)
Also, sort `Cargo.toml` dependencies if they were disordered.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-06-12 17:09:29 +00:00
Harry Barber 11cf41d944
Simplify `Plugin` trait (#2740)
## Motivation and Context

https://github.com/awslabs/smithy-rs/issues/2444

## Description

- Simplify `Plugin`, make it closer to `Layer`.
- Remove `Operation`.
2023-06-12 16:46:58 +00:00
82marbag 5eb0927514
OperationShape::NAME as ShapeId (#2678) (#2717)
See https://github.com/awslabs/smithy-rs/issues/2634

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
Co-authored-by: Harry Barber <106155934+hlbarber@users.noreply.github.com>
2023-06-09 13:33:40 +00:00
Harry Barber 7347c58458
Remove `PollError` from server type parameters (#2457)
## Motivation and Context

https://github.com/awslabs/smithy-rs/issues/2444

## Description

Remove `PollError` from the implementation and documentation.
2023-05-30 20:13:53 +00:00
david-perez cf292d5817
Bump `lambda_http` dependency of `aws-smithy-http-server` to 0.8.0 (#2685) (#2691)
This is https://github.com/awslabs/smithy-rs/pull/2685 again, which was
merged
prematurely and reverted in
https://github.com/awslabs/smithy-rs/pull/2690.

This time we won't merge it until it's due time.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-30 14:47:20 +00:00
Thor Bjorgvinsson 5126a61489
Fix tiny_map from_iter where one operation was being dropped (#2733)
## Motivation and Context
15th operation was being dropped when iterator was being read into a
TinyMap

## Description
The 15th operation was being dropped when the if statement was caught
because the operation had been popped of the iterator but hadn't been
added to the vec of operations before the two iterators were being
chained and collected into a

## Testing
Added unit tests that reproduced the issue and verified that the issue
is fixed

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Co-authored-by: david-perez <d@vidp.dev>
Co-authored-by: Fahad Zubair <fahadzubair@gmail.com>
2023-05-30 11:46:07 +00:00
82marbag c2da4cf16d
Revert "OperationShape::NAME as ShapeId (#2678)" (#2698)
This reverts https://github.com/awslabs/smithy-rs/pull/2678.

It is a breaking change and it will be included in the next release.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-12 09:07:52 +00:00
82marbag 9b340fb89e
OperationShape::NAME as ShapeId (#2678)
See https://github.com/awslabs/smithy-rs/issues/2634

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2023-05-11 15:02:03 +00:00
david-perez a78ac591fe
Revert "Bump `lambda_http` dependency of `aws-smithy-http-server` to 0.8.0 (#2685)" (#2690)
This reverts commit 04db5e3572.

This is a breaking change that needs to wait to be merged in until the
next breaking release.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-10 10:41:28 +00:00
david-perez 04db5e3572
Bump `lambda_http` dependency of `aws-smithy-http-server` to 0.8.0 (#2685)
This patch also removes the unneeded dependency on `lambda_runtime` by
`aws-smithy-http-server-python`.

This patch also refactors `LambdaHandler`'s `convert_event` to avoid
cloning the URI path when not needed.

This is a breaking change. See #2676 why.

This patch also bumps `aws-smithy-http-server` dependency on `mime` to
0.3.4.

`cargo +nightly-2022-11-16 minimal-versions check --all-features`
otherwise
fails when using 0.3.0, because we require `impl fmt::Display for
mime::FromStrError`, which was first introduced in 0.3.4.

As to why `minimal-versions` is now picking `mime` 0.3.0 with this
patch, it's
because in `lambda_http` 0.7.3, they had [`mime =

"0.3.16"`](99dba64472/lambda-http/Cargo.toml (L35-L35)),
and in `lambda_http` 0.8.0, they've now relaxed that to [`mime =

"0.3"`](393d6447be/lambda-http/Cargo.toml (L36)).


## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-10 09:39:15 +00:00
david-perez c3e6ed96df
Document compatibility of `aws-smithy-http-server` with `lambda_http` (#2683)
See #2676.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-05-10 08:18:21 +00:00
82marbag bc4c1862ae
Lazy initialize mime accept header (#2629)
## Description

Do not parse and initialize the mime, known at compile time, on every
request.

See
https://github.com/awslabs/smithy-rs/pull/2607#discussion_r1172607704


## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2023-04-26 08:52:47 +00:00
Julian Antonielli 2de6815c10
Add `AlbHealthCheckLayer` (#2540)
## Motivation and Context
Services often need the ability to report health status via health
checks (see [ALB Health
Checks](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/target-group-health-checks.html)).
This PR adds a simple layer that allows configuring your service to
respond to these health check requests.

## Description
Adds `AlbHealthCheckLayer`, and `AlbHealthCheckService`.

## Testing
Added this layer to the `pokemon-service` binary, and added an
integration test for it.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-04-24 10:25:27 +00:00
david-perez c805f89be6
Undeprecate `{content_type,accept}_header_classifier` from `aws-smithy-http-server` (#2604)
These functions were mistakenly deprecated when deprecating the old
service builder API in #1886.

However, they're fine, and they're internally used by the generated
server SDKs.
The module they reside in is `#[doc(hidden)]`.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-04-20 11:45:08 +00:00
david-perez 2f70ac8ec0
`DEBUG`-log server request rejections (#2597)
This commit logs server request rejections at the `DEBUG` level in an
operation's `FromRequest` implementation.

This commit is analogous to the one in PR #2524 for response rejections.
However, request rejections are _not_ errors, so they shouldn't be
logged at the `ERROR` level. Indeed, they happen every time the server
rejects a malformed request.

Prior to this commit, the `RuntimeError::NotAcceptable` variant was the
only `RuntimeError` variant that was manually constructed. This commit
makes it so that it now results from a conversion from a new
`RequestRejection::NotAcceptable` variant.

We now leverage `futures_util::future::TryFutureExt::map` to map a
future
that uses `RequestRejection` as its error into a future that uses
`RuntimeError`, and centrally log the rejection there. `futures_util` is
already a transitive dependency of server SDKs (via e.g. `hyper` and
`tower`), so adding it is a direct dependency is not worse.

This helps with #2521.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2023-04-19 11:00:17 +00:00
david-perez c7c8285598
Tighten server rejection types (#2542)
Rejection types used to be loose, but now that they are
protocol-specific (see #2517), they can be tightened up to be more
useful.

Where possible, variants now no longer take in the dynamic
`crate::Error`, instead taking in concrete error types arising from
particular fallible invocations in the generated SDKs.This makes it
easier to see how errors arise, and allows for more specific and helpful
error messages that can be logged.

We `#[derive(thiserror::Error)]` on rejection types to cut down on
boilerplate code.

This commit removes the dependency on `strum_macros`.
2023-04-05 10:38:22 +00:00
david-perez f2abe7c695
Improve invalid HTTP status code responses failure mode handling (#2522)
If the model only uses the `@http` trait to define the response code,
Smithy already checks that this is a valid status code, so the
conversion cannot fail, and we can avoid rejecting with
`ResponseRejection::InvalidHttpStatusCode`.

This commit also removes this variant from RPC protocols, where HTTP
binding traits are not allowed, and so this failure mode can never
happen.
2023-04-04 07:58:24 +00:00
david-perez f036223291
Use `aws_smithy_types::primitive::Parse` in the server (#2528)
This further reduces the number of request rejection variants.
https://docs.rs/aws-smithy-types/latest/aws_smithy_types/primitive/trait.Parse.html

Closes #1232.
2023-04-03 14:43:58 +00:00
david-perez f7080760d9
Split `RuntimeError` and `RequestRejection` by protocol (#2517)
As outlined in the [Protocol Specific Errors] of the [Service Builder
Improvements RFC], `RuntimeError` should be split up into smaller,
protocol specific, errors which accurately model the failure cases of
each protocol.

The same goes for `RequestRejection`.

Closes #1703.

[Protocol Specific Errors]: https://github.com/awslabs/smithy-rs/blob/main/design/src/rfcs/rfc0020_service_builder.md#protocol-specific-errors
[Service Builder Improvements RFC]: https://github.com/awslabs/smithy-rs/blob/main/design/src/rfcs/rfc0020_service_builder.md
2023-04-03 13:07:09 +00:00
82marbag d89a90d631
Add request ID to response headers (#2438)
* Add request ID to response headers

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Add parsing test

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Style

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* CHANGELOG

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Fix import

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Panic if ServerRequestIdProviderLayer is not present

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Own value

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Correct docs

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Add order of layer to expect() message

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Remove Box

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Require order of request ID layers

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Revert "Require order of request ID layers"

This reverts commit 147eef26d5f8972b810dc5994e57865a872e44b0.

* One layer to generate and inject the header

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* HeaderName for header name

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* CHANGELOG

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Remove additional layer

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Remove to_owned

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Add tests, remove unnecessary clone

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* take() ResponsePackage instead

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Update docs

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Update docs

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* cargo fmt

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

* Update CHANGELOG

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>

---------

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
Co-authored-by: Daniele Ahmed <ahmeddan@amazon.de>
2023-03-23 09:17:36 +00:00
Harry Barber abbf78fdb9
Make service builder handler setters more flexible (#2442)
* Add generic parameter to the handler setter

* Constrain Pl::Service in Upgrade rather than S

---------

Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
2023-03-22 15:35:35 +00:00
Harry Barber a737694f73
Move examples to root, refactor to workspace, and refactor integration tests (#2481)
* Move examples

* Update documentation

* Add to CI

* Fix CI

* Cleanup

* Fix clippy lints

* Fix documentation

* Bump example dependencies

* Cleanup

* Update documentation

---------

Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
2023-03-22 14:00:21 +00:00
Russell Cohen 05f920f672
Upgrade Tokio to 1.23.1 (RUSTSEC-2023-0001) (#2474) 2023-03-20 17:44:00 +00:00
John DiSanti 87a62ae30f
Eliminate dependency on `futures-macros` (#2460)
The `futures-macros` crate is pulled in by default by `futures-util`,
and depends on `syn`. None of this functionality is used by smithy-rs.
2023-03-17 21:28:54 +00:00
Julian Antonielli 89b5a7e508
Fix rust doc list (#2466) 2023-03-16 23:07:14 +00:00
Zelda Hessler 92952cbe51
Update MSRV to 1.66.1 (#2468)
* update: MSRV to 1.66.1

* add: CHANGELOG.next.toml entry

* update: Dockerfile too

* fix: clippy lints

* fix: sigv4 event_stream.rs clippy lint
update: codegen clippy lint allowlist

* fix: doc lint that's nightly only
add: docs for aws-smithy-http
add: docs for aws-smithy-client
add: docs for aws-smithy-async

* add: more missing docs.

* fix: add more missing docs

* remove: unnecessary & in HttpBindingGenerator
fix: lint name

* fix: another doc import

* fix: test broken by changing compiler error

* fix: even more lints\nadd: lint warns to all smithy runtime crates

* fix: broken doc links

* fix: clippy bug

* fix: don't use modules named lib in codegen tests

* fix: the paginator_canary.rs unnecessary cast
2023-03-16 21:58:14 +00:00
John DiSanti 358d13a09a
Enable the crate reorganization for generic clients (#2448) 2023-03-13 19:00:11 -07:00