MiddlewareConfig#
- class geodesic.boson.MiddlewareConfig(*args, **kwargs)[source]#
Configures the Middleware for a Dataset
Middleware can be applied to a dataset to perform actions on the data before it is returned to the user, but without influencing the underlying data. This can be useful for things like filtering, transforming, or enhancing the data in some way. Middleware can be applied to the search and pixels handlers of a dataset.
Middleware is broken into a few different pieces:
- Search Filters: These are filters that are applied to the search results of a dataset. They can be used to
filter the results of a search based on some criteria. These should ONLY be applied to providers that don’t offer filtering themselves. When in doubt DON’T apply filters. Most providers have them implemented and this is generally not needed. If you’ve implemented a remote provider with a relatively small number of features, this can be useful since implementing filtering on the provider side can be difficult.
- Search Transforms: These are transforms that are applied to the search results of a dataset. They can be used
to rename fields, combine fields, or otherwise modify the results of a search. These can be applied either before or after search filters. In the former case, set search_transforms_before and in the latter case, set search_transforms_after.
- Pixels Transforms: These are transforms that are applied to the pixels handler of a dataset. They can be used
to apply colormaps, rescale pixel values, or otherwise modify the pixels data. Many of them can create new assets in the dataset while some may modifiy existing assets.
All of these middleware types can be applied to a dataset by adding them to the middleware field of a MiddlewareConfig object. The order of these operations is important. The first item in middleware will be applied to the response first, and so on until the last item. Middleware that alters the request must be added after any middleware that alters the response. That is, the responses will be altered by the middleware in a first to last order, and requests will be modified in a last to first order. Filters must be applied AFTER any transforms that they depend on.
Attributes
middleware
(
SearchFilter
,SearchTransform
,PixelsTransform
, dict) - Middleware to apply to a dataset.pixels_transforms
(
PixelsTransform
, dict) - (DEPRECATED) transforms the request/response of a pixels handler.search_filters
(
SearchFilter
, dict) - (DEPRECATED) Which filter actions to perform applied to the result of a dataset.search_transforms_after
(
SearchTransform
, dict) - (DEPRECATED) transforms to be applied to each feature/item in a search response.search_transforms_before
(
SearchTransform
, dict) - (DEPRECATED) transforms to be applied to each feature/item in a search response.Methods
clear
()copy
()fromkeys
([value])Create a new dictionary with keys from iterable and values set to value.
get
(key[, default])Return the value for key if key is in the dictionary, else default.
items
()keys
()pop
(k[,d])If key is not found, default is returned if given, otherwise KeyError is raised
popitem
()Remove and return a (key, value) pair as a 2-tuple.
setdefault
(key[, default])Insert key with a value of default if key is not in the dictionary.
update
(*mapping, **kwargs)values
()