Routing¶
-
class
uwsgiconf.options.routing.
RouteRule
(action, subject=None, stage='')¶ Represents a routing rule.
Parameters: - action (RouteAction) – Action (or transformation) to perfrom.
See
.actions
and.transforms
. - subject (SubjectCustom|SubjectBuiltin|str) –
Subject to verify before action is performed. See
.subjects
.- String values are automatically transformed into
subjects.path_info
. - If
None
action is performed always w/o subject check.
- String values are automatically transformed into
- stage (str) – Stage on which the action needs to be performed.
See
.stages
.
-
class
var_functions
¶ Functions that can be applied to variables.
-
base64
¶
-
hex
¶
-
lower
¶
-
math
¶
-
mime
¶
-
upper
¶
-
-
class
stages
¶ During the request cycle, various stages (aka chains) are processed.
Chains can be “recursive”. A recursive chain can be called multiple times in a request cycle.
-
REQUEST
= ''¶ Applied before the request is passed to the plugin.
-
ERROR
= 'error'¶ Applied as soon as an HTTP status code is generate. Recursive chain.
-
RESPONSE
= 'response'¶ Applied after the last response header has been generated (just before sending the body).
-
FINAL
= 'final'¶ Applied after the response has been sent to the client.
-
-
class
subjects
¶ Routing subjects. These can be request’s variables or other entities.
Note
Non-custom subjects can be pre-optimized (during startup) and should be used for performance reasons.
-
custom
¶
-
http_host
¶
-
http_referer
¶ alias of
uwsgiconf.options.routing_subjects.SubjectHttpReferer
-
http_user_agent
¶ alias of
uwsgiconf.options.routing_subjects.SubjectHttpUserAgent
-
path_info
¶
-
query_string
¶ alias of
uwsgiconf.options.routing_subjects.SubjectQueryString
-
remote_addr
¶ alias of
uwsgiconf.options.routing_subjects.SubjectRemoteAddr
-
remote_user
¶ alias of
uwsgiconf.options.routing_subjects.SubjectRemoteUser
-
request_uri
¶ alias of
uwsgiconf.options.routing_subjects.SubjectRequestUri
-
status
¶
-
-
class
transforms
¶ A transformation is like a filter applied to the response generated by your application.
Transformations can be chained (the output of a transformation will be the input of the following one) and can completely overwrite response headers.
-
chunked
¶
-
fix_content_len
¶ alias of
uwsgiconf.options.routing_actions.ActionFixContentLen
-
flush
¶
-
gzip
¶
-
template
¶
-
to_file
¶
-
upper
¶
-
-
class
actions
¶ Actions available for routing rules.
Values returned by actions:
NEXT
- continue to the next ruleCONTINUE
- stop scanning the internal routing table and run the requestBREAK
- stop scanning the internal routing table and close the requestGOTO x
- go to rulex
-
add_var_cgi
¶
-
add_var_log
¶
-
alarm
¶
-
auth_basic
¶
-
auth_ldap
¶
-
dir_change
¶
-
do_break
¶
-
do_continue
¶
-
do_goto
¶
-
fix_var_path_info
¶ alias of
uwsgiconf.options.routing_actions.ActionFixVarPathInfo
-
header_add
¶
-
header_remove
¶ alias of
uwsgiconf.options.routing_actions.ActionHeaderRemove
-
headers_off
¶
-
headers_reset
¶ alias of
uwsgiconf.options.routing_actions.ActionHeadersReset
-
log
¶
-
offload_off
¶
-
redirect
¶
-
rewrite
¶
-
route_external
¶ alias of
uwsgiconf.options.routing_actions.ActionRouteExternal
-
route_uwsgi
¶
-
send
¶
-
serve_static
¶ alias of
uwsgiconf.options.routing_actions.ActionServeStatic
-
set_harakiri
¶ alias of
uwsgiconf.options.routing_actions.ActionSetHarakiri
-
set_script_file
¶ alias of
uwsgiconf.options.routing_actions.ActionSetScriptFile
-
set_uwsgi_process_name
¶ alias of
uwsgiconf.options.routing_actions.ActionSetUwsgiProcessName
-
set_var_document_root
¶ alias of
uwsgiconf.options.routing_actions.ActionSetVarDocumentRoot
-
set_var_path_info
¶ alias of
uwsgiconf.options.routing_actions.ActionSetVarPathInfo
-
set_var_remote_addr
¶ alias of
uwsgiconf.options.routing_actions.ActionSetVarRemoteAddr
-
set_var_remote_user
¶ alias of
uwsgiconf.options.routing_actions.ActionSetVarRemoteUser
-
set_var_request_method
¶ alias of
uwsgiconf.options.routing_actions.ActionSetVarRequestMethod
-
set_var_request_uri
¶ alias of
uwsgiconf.options.routing_actions.ActionSetVarRequestUri
-
set_var_script_name
¶ alias of
uwsgiconf.options.routing_actions.ActionSetVarScriptName
-
set_var_uwsgi_appid
¶ alias of
uwsgiconf.options.routing_actions.ActionSetVarUwsgiAppid
-
set_var_uwsgi_home
¶ alias of
uwsgiconf.options.routing_actions.ActionSetVarUwsgiHome
-
set_var_uwsgi_scheme
¶ alias of
uwsgiconf.options.routing_actions.ActionSetVarUwsgiScheme
-
signal
¶
- action (RouteAction) – Action (or transformation) to perfrom.
See
-
class
uwsgiconf.options.routing.
Routing
(*args, **kwargs)¶ Routing subsystem.
You can use the internal routing subsystem to dynamically alter the way requests are handled.
Note
Since 1.9
- http://uwsgi.readthedocs.io/en/latest/InternalRouting.html
- http://uwsgi.readthedocs.io/en/latest/Transformations.html
-
class
routers
¶ Dedicated routers, which can be used with register_router().
-
http
¶
-
https
¶
-
ssl
¶
-
fast
¶
-
raw
¶
-
forkpty
¶
-
tuntap
¶
-
-
class
modifiers
¶ Routing modifiers.
-
cache
¶
-
cgi
¶
-
cluster_node
¶ alias of
uwsgiconf.options.routing_modifiers.ModifierClusterNode
-
config_from_node
¶ alias of
uwsgiconf.options.routing_modifiers.ModifierConfigFromNode
-
corerouter_signal
¶ alias of
uwsgiconf.options.routing_modifiers.ModifierCorerouterSignal
-
echo
¶
-
eval
¶
-
example
¶ alias of
uwsgiconf.options.routing_modifiers.ModifierExample
-
fastfunc
¶ alias of
uwsgiconf.options.routing_modifiers.ModifierFastfunc
-
glusterfs
¶ alias of
uwsgiconf.options.routing_modifiers.ModifierGlusterfs
-
gridfs
¶
-
jvm
¶
-
legion_msg
¶ alias of
uwsgiconf.options.routing_modifiers.ModifierLegionMsg
-
lua
¶
-
manage
¶
-
manage_path_info
¶ alias of
uwsgiconf.options.routing_modifiers.ModifierManagePathInfo
-
message
¶ alias of
uwsgiconf.options.routing_modifiers.ModifierMessage
-
message_array
¶ alias of
uwsgiconf.options.routing_modifiers.ModifierMessageArray
-
message_marshal
¶ alias of
uwsgiconf.options.routing_modifiers.ModifierMessageMarshal
-
mono
¶
-
multicast
¶ alias of
uwsgiconf.options.routing_modifiers.ModifierMulticast
-
multicast_announce
¶ alias of
uwsgiconf.options.routing_modifiers.ModifierMulticastAnnounce
-
persistent_close
¶ alias of
uwsgiconf.options.routing_modifiers.ModifierPersistentClose
-
php
¶
-
ping
¶
-
psgi
¶
-
rack
¶
-
rados
¶
-
raw
¶
-
reload
¶
-
reload_brutal
¶ alias of
uwsgiconf.options.routing_modifiers.ModifierReloadBrutal
-
remote_logging
¶ alias of
uwsgiconf.options.routing_modifiers.ModifierRemoteLogging
-
response
¶ alias of
uwsgiconf.options.routing_modifiers.ModifierResponse
-
rpc
¶
-
signal
¶
-
snmp
¶
-
spooler
¶ alias of
uwsgiconf.options.routing_modifiers.ModifierSpooler
-
subscription
¶ alias of
uwsgiconf.options.routing_modifiers.ModifierSubscription
-
symcall
¶ alias of
uwsgiconf.options.routing_modifiers.ModifierSymcall
-
v8
¶
-
wsgi
¶
-
xslt
¶
-
-
use_router
(router, *, force=None)¶ Parameters: - router (RouterBase) – Dedicated router object. See .routers.
- force (bool) – All of the gateways (routers) has to be run under the master process, supplying this you can try to bypass this limit.
-
register_route
(route_rules, *, label=None)¶ Registers a routing rule.
Parameters: - route_rules (RouteRule|list[RouteRule]) –
- label (str) –
Label to mark the given set of rules. This can be used in conjunction with
do_goto
rule action.
-
print_routing_rules
()¶ Print out supported routing rules (actions, transforms, etc.).
-
set_error_page
(status: int, html_fpath: str)¶ Add an error page (html) for managed 403, 404, 500 response.
Parameters: - status – HTTP status code.
- html_fpath – HTML page file path.
-
set_error_pages
(codes_map: dict = None, *, common_prefix: str = None)¶ Add an error pages for managed 403, 404, 500 responses.
Shortcut for
.set_error_page()
.Parameters: - codes_map –
Status code mapped into an html filepath or just a filename if common_prefix is used.
If not set, filename containing status code is presumed: 400.html, 500.html, etc.
- common_prefix – Common path (prefix) for all files.
- codes_map –
-
set_geoip_params
(*, db_country=None, db_city=None)¶ Sets GeoIP parameters.
Parameters: - db_country (str) – Country database file path.
- db_city (str) – City database file path. Example:
GeoLiteCity.dat
.
-
header_add
(name, value)¶ Automatically add HTTP headers to response.
Parameters: - name (str) –
- value (str) –
-
header_remove
(value)¶ Automatically remove specified HTTP header from the response.
Parameters: value (str) –
-
header_collect
(name, target_var, *, pull=False)¶ Store the specified response header in a request var (optionally removing it from the response).
Parameters: - name (str) –
- target_var (str) –
- pull (bool) – Whether to remove header from response.