krait.config module¶
This module is used to configure the behaviour of Krait when a request arrives and when its response is sent. Currently, this module is used to configure routing and the client-side cache.
The members of this module should only be changed from .py/init.py, later changes are ignored.
Reference¶
-
class
krait.config.Route(verb=None, url=None, regex=None, target=None)[source]¶ Bases:
objectSignifies a route that incoming requests can take.
Parameters: - verb (str, optional) – The routing verb (most HTTP verbs, plus
ANYandWEBSOCKET). SeeRoute.route_verbsfor options; GET by default - url (str, optional) – The URL to match, or None to skip
- regex (str, optional) – The regex to match, or None to skip
- target (str, optional) – The target of the route, or None to keep default target (extracted from URL)
-
verb¶ str – The routing verb
-
url¶ str, optional – The URL to match, or None to skip
-
regex¶ str, optional – The regex to match, or None to skip
-
target¶ str, optional – The target of the route. None keeps default target (extracted from the URL)
-
route_verbs= ['GET', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'ANY', 'WEBSOCKET']¶ The route verb options.
- verb (str, optional) – The routing verb (most HTTP verbs, plus
-
krait.config.routes= None¶ list of
Route– The list of routes to be read by Krait. The default is all GETs to default targets, deny anything else. If you override this, the last route should be a default one (Route()) to allow GET requests to reach resources that aren’t explicitly routed (like CSS or Javascript files)
-
krait.config.cache_no_store= []¶ list of str – The list of filename regexes that the clients shouldn’t cache.
-
krait.config.cache_private= []¶ list of str – The list or filename regexes that only private (client) caches should keep. This usually means that browser caches can keep the resource, but not shared caches.
-
krait.config.cache_public= []¶ list of str – The list of filename regexes that can be kept in any caches.
-
krait.config.cache_long_term= []¶ list of str – The list of filename regexes that can be kept for a longer time. This duration is configured with
krait.config.cache_max_age_long_termThis is a modifier, so it can be applied to both private or public cache directives.
-
krait.config.cache_max_age_default= 300¶ int – The number of seconds that clients should not re-request the resource. This corresponds to the Max-Age of the HTTP response, for public or private (and not long-term) cached resources.
-
krait.config.cache_max_age_long_term= 864000¶ int – The number of seconds that clients should not re-request the resource, for long-term cached resources. This corresponds to the Max-Age of the HTTP responses, for long-term, public or private, cached resources.