`aws-smithy-http-server`: implement basic URI pattern conflict disambiguation (#1036)
This commit implements basic URI pattern conflict disambiguation when routing incoming requests to service operations. It does this by introducing a measure of how "important" a `RequestSpec` is. The more specific a `RequestSpec` is, the higher it ranks in importance. Specificity is measured by the number of segments plus the number of query string literals in its URI pattern, so `/{Bucket}/{Key}?query` is more specific than `/{Bucket}/{Key}`, which is more specific than `/{Bucket}`, which is more specific than `/`. Why do we need this? Note that: 1. the Smithy spec does not define how servers should route incoming requests in the case of pattern conflicts; and 2. the Smithy spec even outright rejects conflicting patterns that can be easily disambiguated e.g. `/{a}` and `/{label}/b` cannot coexist. We can't to anything about (2) since the Smithy CLI will refuse to build a model with those kind of conflicts. However, the Smithy CLI does allow _other_ conflicting patterns to coexist, e.g. `/` and `/{label}`. We therefore have to take a stance on (1), since if we route arbitrarily we render basic usage impossible (see issue #1009). So this ranking of routes implements some basic pattern conflict disambiguation with some common sense. It's also the same behavior that the TypeScript sSDK is implementing [0]. This commit also: * makes the `future` module private, * hides documentation for the `request_spec` module; and * makes some fields from some structs in the `request_spec` module private and adds constructors. Closes #1009. [1]: https://github.com/awslabs/smithy-typescript/blob/d263078b81485a6a2013d243639c0c680343ff47/smithy-typescript-ssdk-libs/server-common/src/httpbinding/mux.ts#L59.
Loading
Please register or sign in to comment