Actions¶
-
class
uwsgiconf.options.routing_actions.
RouteAction
(*args)¶
-
class
uwsgiconf.options.routing_actions.
ActionFlush
¶ Send the current contents of the transformation buffer to the client (without clearing the buffer).
-
class
uwsgiconf.options.routing_actions.
ActionGzip
¶ Encodes the response buffer to gzip.
-
class
uwsgiconf.options.routing_actions.
ActionToFile
(filename, *, mode=None)¶ Used for caching a response buffer into a static file.
-
class
uwsgiconf.options.routing_actions.
ActionUpper
¶ Transforms each character in uppercase.
Mainly as an example of transformation plugin.
-
class
uwsgiconf.options.routing_actions.
ActionChunked
¶ Encodes the output in HTTP chunked.
-
class
uwsgiconf.options.routing_actions.
ActionTemplate
¶ Allows using a template file to expose everything from internal routing system into it.
-
class
uwsgiconf.options.routing_actions.
ActionFixContentLen
(*, add_header=False)¶ Fixes Content-length header.
Parameters: add_header (bool) – Force header add instead of plain fix of existing header.
-
class
uwsgiconf.options.routing_actions.
ActionDoContinue
¶ Stop scanning the internal routing table and continue to the selected request handler.
-
class
uwsgiconf.options.routing_actions.
ActionDoBreak
(code, *, return_body=False)¶ Stop scanning the internal routing table and close the request.
Parameters: - code (int) – HTTP code
- return_body – Uses uWSGI’s built-in status code and returns both status code and message body.
-
class
uwsgiconf.options.routing_actions.
ActionLog
(message)¶ Print the specified message in the logs or do not log a request is
message
isNone
.Parameters: message (str|None) – Message to add into log. If None
logging will be disabled for this request.
-
class
uwsgiconf.options.routing_actions.
ActionOffloadOff
¶ Do not use offloading.
-
class
uwsgiconf.options.routing_actions.
ActionAddVarLog
(name, val)¶ Add the specified logvar.
Parameters: - name (str) – Variable name.
- val – Variable value.
-
class
uwsgiconf.options.routing_actions.
ActionDoGoto
(where)¶ Make a forward jump to the specified label or rule position.
Parameters: where (str|int) – Rule number of label to go to.
-
class
uwsgiconf.options.routing_actions.
ActionAddVarCgi
(name, val)¶ Add the specified CGI (environment) variable to the request.
Parameters: - name (str) – Variable name.
- val – Variable value.
-
class
uwsgiconf.options.routing_actions.
ActionHeaderAdd
(name, val)¶ Add the specified HTTP header to the response.
Parameters: - name (str) – Header name.
- val – Header value.
-
class
uwsgiconf.options.routing_actions.
ActionHeaderRemove
(name)¶ Remove the specified HTTP header from the response.
Parameters: name (str) – Header name.
-
class
uwsgiconf.options.routing_actions.
ActionHeadersOff
¶ Disable headers.
-
class
uwsgiconf.options.routing_actions.
ActionHeadersReset
(code)¶ Clear the response headers, setting a new HTTP status code, useful for resetting a response.
Parameters: code (int) – HTTP code.
-
class
uwsgiconf.options.routing_actions.
ActionSignal
(num)¶ Raise the specified uwsgi signal.
Parameters: num (int) – Signal number.
-
class
uwsgiconf.options.routing_actions.
ActionSend
(data, *, crnl: bool = False)¶ Extremely advanced (and dangerous) function allowing you to add raw data to the response.
Parameters: - data – Data to add to response.
- crnl – Add carriage return and new line.
-
class
uwsgiconf.options.routing_actions.
ActionRedirect
(url, *, permanent=False)¶ Return a HTTP 301/302 Redirect to the specified URL.
Parameters: - url (str) – URL to redirect to.
- permanent (bool) – If
True
use 301, otherwise 302.
-
class
uwsgiconf.options.routing_actions.
ActionRewrite
(rule, *, do_continue=False)¶ A rewriting engine inspired by Apache mod_rewrite.
Rebuild PATH_INFO and QUERY_STRING according to the specified rules before the request is dispatched to the request handler.
Parameters: - rule (str) – A rewrite rule.
- do_continue (bool) – Stop request processing and continue to the selected request handler.
-
class
uwsgiconf.options.routing_actions.
ActionRouteUwsgi
(external_address='', *, modifier='', app='')¶ Rewrite the modifier1, modifier2 and optionally UWSGI_APPID values of a request or route the request to an external uwsgi server.
Parameters: - external_address (str) – External uWSGI server address (host:port).
- modifier (Modifier) – Set request modifier.
- app (str) – Set
UWSGI_APPID
.
-
class
uwsgiconf.options.routing_actions.
ActionRouteExternal
(address, *, host_header=None)¶ Route the request to an external HTTP server.
Parameters: - address (str) – External HTTP address (host:port)
- host_header (str) – HOST header value.
-
class
uwsgiconf.options.routing_actions.
ActionAlarm
(name, message)¶ Triggers an alarm.
Parameters: - name (str) – Alarm name
- message (str) – Message to pass into alarm.
-
class
uwsgiconf.options.routing_actions.
ActionServeStatic
(fpath: Union[str, pathlib.Path])¶ Serve a static file from the specified physical path.
Parameters: fpath – Static file path.
-
class
uwsgiconf.options.routing_actions.
ActionAuthBasic
(realm, *, user=None, password=None, do_next=False)¶ Use Basic HTTP Auth.
Parameters: - realm (str) –
- user (str) –
- password (str) – Password or htpasswd-like file.
- do_next (bool) – Allow next rule.
-
class
uwsgiconf.options.routing_actions.
AuthLdap
(realm, address, *, base_dn=None, bind_dn=None, bind_password=None, filter=None, login_attr=None, log_level=None, do_next=False)¶ Use Basic HTTP Auth.
Parameters: - realm (str) –
- address (str) – LDAP server URI
- base_dn (str) – Base DN used when searching for users.
- bind_dn (str) – DN used for binding. Required if the LDAP server does not allow anonymous searches.
- bind_password (str) – Password for the
bind_dn
user. - filter (str) – Filter used when searching for users. Default:
(objectClass=*)
- login_attr (str) – LDAP attribute that holds user login. Default:
uid
. - log_level (str) –
Log level.
- Supported values:
- 0 - don’t log any binds
- 1 - log authentication errors,
- 2 - log both successful and failed binds
- do_next (bool) – Allow next rule.
-
class
uwsgiconf.options.routing_actions.
ActionSetHarakiri
(timeout)¶ Set harakiri timeout for the current request.
Parameters: timeout (int) –
-
class
uwsgiconf.options.routing_actions.
ActionDirChange
(dir)¶ Changes a directory.
Parameters: dir (str) – Directory to change into.
-
class
uwsgiconf.options.routing_actions.
ActionSetVarUwsgiAppid
(app)¶ Set UWSGI_APPID.
Bypass
SCRIPT_NAME
andVirtualHosting
to let the user choose the mountpoint without limitations (or headaches).The concept is very generic:
UWSGI_APPID
is the identifier of an application. If it is not found in the internal list of apps, it will be loaded.Parameters: app (str) – Application ID.
-
class
uwsgiconf.options.routing_actions.
ActionSetVarRemoteUser
(user)¶ Set REMOTE_USER
Parameters: user (str) – Username.
-
class
uwsgiconf.options.routing_actions.
ActionSetVarUwsgiHome
(dir)¶ Set UWSGI_HOME
Parameters: dir (str) – Directory to make a new home.
-
class
uwsgiconf.options.routing_actions.
ActionSetVarUwsgiScheme
(value)¶ Set UWSGI_SCHEME.
Set the URL scheme when it cannot be reliably determined. This may be used to force HTTPS (with the value
https
), for instance.Parameters: value (str) –
-
class
uwsgiconf.options.routing_actions.
ActionSetVarScriptName
(name)¶ Set SCRIPT_NAME
Parameters: name (str) – Script name
-
class
uwsgiconf.options.routing_actions.
ActionSetVarRequestMethod
(name)¶ Set REQUEST_METHOD
Parameters: name (str) – Method name.
-
class
uwsgiconf.options.routing_actions.
ActionSetVarRequestUri
(value)¶ Set REQUEST_URI
Parameters: value (str) – URI
-
class
uwsgiconf.options.routing_actions.
ActionSetVarRemoteAddr
(value)¶ Set REMOTE_ADDR
Parameters: value (str) – Address.
-
class
uwsgiconf.options.routing_actions.
ActionSetVarPathInfo
(value)¶ Set PATH_INFO
Parameters: value (str) – New info.
-
class
uwsgiconf.options.routing_actions.
ActionSetVarDocumentRoot
(value)¶ Set DOCUMENT_ROOT
Parameters: value (str) –
-
class
uwsgiconf.options.routing_actions.
ActionSetUwsgiProcessName
(name)¶ Set uWSGI process name.
Parameters: name (str) – New process name.
-
class
uwsgiconf.options.routing_actions.
ActionFixVarPathInfo
¶ Fixes PATH_INFO taking into account script name.
This action allows you to set SCRIPT_NAME in nginx without bothering to rewrite the PATH_INFO (something nginx cannot afford).
-
class
uwsgiconf.options.routing_actions.
ActionSetScriptFile
(fpath: Union[str, pathlib.Path])¶ Set script file.
Parameters: fpath (str) – File path.