This change imports (with slight modification) the
MicroversionMiddleware created for the placement service.
For the time being the middleware relies on WebOb as that is
what it originally relied on. If there are requirements to do
otherwise, later, we can make adjustments then.
The README is updated with limited usage instructions.
Gabbi tests are added, requiring adjustments to the test configuration,
so the opportunity was taken to switch to using stestr instead of testr.
Though arguably "functional" tests because they are not strictly unit
tests, no distinction is made in the tests directory, for now, as it
is all nice and fast and we'd like to keep it that way.
Change-Id: I9d27b6fad35f7aea0085f08c0353f8e8acdb8b73
This change imports two functions and a class from the microversion
handling implementation in the placement service. This code should be
generally useful for other implementations.
The added code provides functions for not just extracting the
microversion from HTTP headers, but for validating that the found
information is actually a properly formed microversion value.
'latest' is translated to whatever latest is in an ordered list of
versions and any found version is confirmed to be within the bounds of
and a member of that list of versions.
The README.rst has been updated to reflect the newly available methods.
This is a start at documentation, but we'll probably want more.
Change-Id: I267586c78308cc5520a88598c350a7e055783f3e
The get_version method accepts a dict or list of tuples that
represent HTTP request headers that will be processed to find a
microversion header. Sometimes, for example in some middlewares,
direct access to a headers dict will not be available and only the
WSGI environ will be present.
This change provides a utility method which creates a new dict of
headers: headers_from_wsgi_environ. This mode was chosen to make it
clear that a copy of the environ is being made, not the environ
itself as we really don't want to be passing that as some values in
it will not be simple objects (strings and numbers) and we do not
know what other middleware might have done or want to do with it.
Internal to get_version any attempt to get a header named 'FOO' will
fall back to looking for the WSGI equivalent of 'HTTP_FOO'.
README.rst has been updated to indicate the new style.
This change is backwards compatible, existing clients will not
notice.
Change-Id: I5262031d9cde0378eabe342c1913091658c3bf9b
Closes-Bug: #1579772
See README.rst for details.
The basic gist is that a get_version method is provided. It takes a
dict or list of headers and returned a version for a service_type if
it can find it.