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.HttpMasterMiddleware(context)[source]
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]

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.HttpPlugin(context)[source]

A base interface for HTTP request handling:

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

Finds and executes the handler for given request context (handlers were methods decorated with url() and will be decorated with e.g. @get and @post in the future)

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.copy(pattern)

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

aj.api.http.delete(pattern)

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

aj.api.http.get(pattern)

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

aj.api.http.head(pattern)

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

aj.api.http.lock(pattern)

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

aj.api.http.mkcol(pattern)

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

aj.api.http.move(pattern)

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

aj.api.http.options(pattern)

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

aj.api.http.patch(pattern)

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

aj.api.http.post(pattern)

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

aj.api.http.propfind(pattern)

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

aj.api.http.proppatch(pattern)

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

aj.api.http.put(pattern)

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

aj.api.http.requests_decorator_generator(method)[source]

Factorization to generate request decorators like @get or @post.

Parameters:method (basestring) – Request method decorator to generate, like get or post
Returns:
Return type:
aj.api.http.unlock(pattern)

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

aj.api.http.url(pattern)[source]

Exposes the decorated method of your HttpPlugin via HTTP. Will be deprecated in favor of new decorators ( @get, @post, … )

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