API: aj.api.http

class aj.api.http.BaseHttpHandler[source]

Base class for everything that can process HTTP requests

handle(http_context)[source]

Should create a HTTP response in the given http_context and return the plain output

Parameters:http_context (aj.http.HttpContext) – HTTP context
class aj.api.http.HttpMiddleware(context)[source]
handle(http_context)[source]
class aj.api.http.HttpPlugin(context)[source]

A base interface for HTTP request handling:

@component
class HelloHttp(HttpPlugin):
    @url('/hello/(?P<name>.+)')
    def get_page(self, http_context, name=None):
        context.add_header('Content-Type', 'text/plain')
        context.respond_ok()
        return 'Hello, %s!' % name
handle(http_context)[source]

Finds and executes the handler for given request context (handlers are methods decorated with url() )

Parameters:http_context (aj.http.HttpContext) – HTTP context
Returns:reponse data
class aj.api.http.SocketEndpoint(context)[source]

Base interface for Socket.IO endpoints.

destroy()[source]

Destroys endpoint, killing the running greenlets

on_connect(message)[source]

Called on a successful client connection

on_disconnect(message)[source]

Called on a client disconnect

on_message(message, *args)[source]

Called when a socket message arrives to this endpoint

plugin = None

arbitrary plugin ID for socket message routing

send(data, plugin=None)[source]

Sends a message to the client.the

Parameters:
  • data – message object
  • plugin (str) – routing ID (this endpoint’s ID if not specified)
spawn(target, *args, **kwargs)[source]

Spawns a greenlet in this endpoint, which will be auto-killed when the client disconnects

Parameters:target – target function
aj.api.http.url(pattern)[source]

Exposes the decorated method of your HttpPlugin via HTTP

Parameters:pattern (str) – URL regex (^ and $ are implicit)
Return type:function

Named capture groups will be fed to function as **kwargs


Comments

comments powered by Disqus