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.
  • stage (str|unicode) – Stage on which the action needs to be performed. See .stages.
class vars

Routing variables.

cookie

alias of uwsgiconf.options.routing_vars.VarCookie

geoip

alias of uwsgiconf.options.routing_vars.VarGeoip

httptime

alias of uwsgiconf.options.routing_vars.VarHttptime

metric

alias of uwsgiconf.options.routing_vars.VarMetric

query

alias of uwsgiconf.options.routing_vars.VarQuery

request

alias of uwsgiconf.options.routing_vars.VarRequest

time

alias of uwsgiconf.options.routing_vars.VarTime

uwsgi

alias of uwsgiconf.options.routing_vars.VarUwsgi

class var_functions

Functions that can be applied to variables.

base64

alias of uwsgiconf.options.routing_vars.FuncBase64

hex

alias of uwsgiconf.options.routing_vars.FuncHex

lower

alias of uwsgiconf.options.routing_vars.FuncLower

math

alias of uwsgiconf.options.routing_vars.FuncMath

mime

alias of uwsgiconf.options.routing_vars.FuncMime

upper

alias of uwsgiconf.options.routing_vars.FuncUpper

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

alias of uwsgiconf.options.routing_subjects.SubjectCustom

http_host

alias of uwsgiconf.options.routing_subjects.SubjectHttpHost

http_referer

alias of uwsgiconf.options.routing_subjects.SubjectHttpReferer

http_user_agent

alias of uwsgiconf.options.routing_subjects.SubjectHttpUserAgent

path_info

alias of uwsgiconf.options.routing_subjects.SubjectPathInfo

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

alias of uwsgiconf.options.routing_subjects.SubjectStatus

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

alias of uwsgiconf.options.routing_actions.ActionChunked

fix_content_len

alias of uwsgiconf.options.routing_actions.ActionFixContentLen

flush

alias of uwsgiconf.options.routing_actions.ActionFlush

gzip

alias of uwsgiconf.options.routing_actions.ActionGzip

template

alias of uwsgiconf.options.routing_actions.ActionTemplate

to_file

alias of uwsgiconf.options.routing_actions.ActionToFile

upper

alias of uwsgiconf.options.routing_actions.ActionUpper

class actions

Actions available for routing rules.

Values returned by actions:

  • NEXT - continue to the next rule
  • CONTINUE - stop scanning the internal routing table and run the request
  • BREAK - stop scanning the internal routing table and close the request
  • GOTO x - go to rule x
add_var_cgi

alias of uwsgiconf.options.routing_actions.ActionAddVarCgi

add_var_log

alias of uwsgiconf.options.routing_actions.ActionAddVarLog

alarm

alias of uwsgiconf.options.routing_actions.ActionAlarm

auth_basic

alias of uwsgiconf.options.routing_actions.ActionAuthBasic

auth_ldap

alias of uwsgiconf.options.routing_actions.AuthLdap

dir_change

alias of uwsgiconf.options.routing_actions.ActionDirChange

do_break

alias of uwsgiconf.options.routing_actions.ActionDoBreak

do_continue

alias of uwsgiconf.options.routing_actions.ActionDoContinue

do_goto

alias of uwsgiconf.options.routing_actions.ActionDoGoto

fix_var_path_info

alias of uwsgiconf.options.routing_actions.ActionFixVarPathInfo

header_add

alias of uwsgiconf.options.routing_actions.ActionHeaderAdd

header_remove

alias of uwsgiconf.options.routing_actions.ActionHeaderRemove

headers_off

alias of uwsgiconf.options.routing_actions.ActionHeadersOff

headers_reset

alias of uwsgiconf.options.routing_actions.ActionHeadersReset

log

alias of uwsgiconf.options.routing_actions.ActionLog

offload_off

alias of uwsgiconf.options.routing_actions.ActionOffloadOff

redirect

alias of uwsgiconf.options.routing_actions.ActionRedirect

rewrite

alias of uwsgiconf.options.routing_actions.ActionRewrite

route_external

alias of uwsgiconf.options.routing_actions.ActionRouteExternal

route_uwsgi

alias of uwsgiconf.options.routing_actions.ActionRouteUwsgi

send

alias of uwsgiconf.options.routing_actions.ActionSend

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

alias of uwsgiconf.options.routing_actions.ActionSignal

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

route_rule

alias of RouteRule

class routers

Dedicated routers, which can be used with register_router().

http

alias of uwsgiconf.options.routing_routers.RouterHttp

https

alias of uwsgiconf.options.routing_routers.RouterHttps

ssl

alias of uwsgiconf.options.routing_routers.RouterSsl

fast

alias of uwsgiconf.options.routing_routers.RouterFast

raw

alias of uwsgiconf.options.routing_routers.RouterRaw

forkpty

alias of uwsgiconf.options.routing_routers.RouterForkPty

tuntap

alias of uwsgiconf.options.routing_routers.RouterTunTap

class modifiers

Routing modifiers.

cache

alias of uwsgiconf.options.routing_modifiers.ModifierCache

cgi

alias of uwsgiconf.options.routing_modifiers.ModifierCgi

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

alias of uwsgiconf.options.routing_modifiers.ModifierEcho

eval

alias of uwsgiconf.options.routing_modifiers.ModifierEval

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

alias of uwsgiconf.options.routing_modifiers.ModifierGridfs

jvm

alias of uwsgiconf.options.routing_modifiers.ModifierJvm

legion_msg

alias of uwsgiconf.options.routing_modifiers.ModifierLegionMsg

lua

alias of uwsgiconf.options.routing_modifiers.ModifierLua

manage

alias of uwsgiconf.options.routing_modifiers.ModifierManage

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

alias of uwsgiconf.options.routing_modifiers.ModifierMono

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

alias of uwsgiconf.options.routing_modifiers.ModifierPhp

ping

alias of uwsgiconf.options.routing_modifiers.ModifierPing

psgi

alias of uwsgiconf.options.routing_modifiers.ModifierPsgi

rack

alias of uwsgiconf.options.routing_modifiers.ModifierRack

rados

alias of uwsgiconf.options.routing_modifiers.ModifierRados

raw

alias of uwsgiconf.options.routing_modifiers.ModifierRaw

reload

alias of uwsgiconf.options.routing_modifiers.ModifierReload

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

alias of uwsgiconf.options.routing_modifiers.ModifierRpc

signal

alias of uwsgiconf.options.routing_modifiers.ModifierSignal

snmp

alias of uwsgiconf.options.routing_modifiers.ModifierSnmp

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

alias of uwsgiconf.options.routing_modifiers.ModifierV8

wsgi

alias of uwsgiconf.options.routing_modifiers.ModifierWsgi

xslt

alias of uwsgiconf.options.routing_modifiers.ModifierXslt

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:
print_routing_rules()

Print out supported routing rules (actions, transforms, etc.).

set_error_page(status, html_fpath)

Add an error page (html) for managed 403, 404, 500 response.

Parameters:
  • status (int) – HTTP status code.
  • html_fpath (str|unicode) – HTML page file path.
set_error_pages(codes_map=None, common_prefix=None)

Add an error pages for managed 403, 404, 500 responses.

Shortcut for .set_error_page().

Parameters:
  • codes_map (dict) –

    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 (str|unicode) – Common path (prefix) for all files.
set_geoip_params(db_country=None, db_city=None)

Sets GeoIP parameters.

Parameters:
  • db_country (str|unicode) – Country database file path.
  • db_city (str|unicode) – City database file path. Example: GeoLiteCity.dat.
header_add(name, value)

Automatically add HTTP headers to response.

Parameters:
  • name (str|unicode) –
  • value (str|unicode) –
header_remove(value)

Automatically remove specified HTTP header from the response.

Parameters:value (str|unicode) –
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|unicode) –
  • target_var (str|unicode) –
  • pull (bool) – Whether to remove header from response.