Request Object¶
Apart from the request attributes provided by Sanic
’s
request object, Insanic
Request Class creates additional attributes
with a lot of inspiration from Django REST Framework, especially for
authentication.
Extra Attributes¶
Request Parsing¶
request.data
Like with Django REST Framework, data provides the parsed content of the request body. It includes all data including file and non-file inputs without needing to worry about the
content-type
.
request.query_params
An alias for Sanic’s
request.args
, it includes all the query parameters in the request.
Authentication¶
request.user
:Depending on the authentication class declared in the class views, this will return an
User
object or be an instance ofAnonymousUser
. Like with Django REST Framework, authentication is done lazily. First access will evaluate if the request is from a authenticated user.View the insanic.models for more information.
request.service
If the request is from another contracted service(i.e. another
Insanic
service), request information about the requested service is accessible with this attribute.
See Also…¶
Django REST Framework Requests documentation.
Sanic Requests documentation.