Class: QgsServerApiContext¶
- class qgis.server.QgsServerApiContext¶
Bases:
sip.wrapper
The
QgsServerApiContext
class encapsulates the resources for a particular client request: the request and response objects, the project (might be NULL) and the server interface, the API root path that matched the request is also added.QgsServerApiContext
is lightweight copyable object meant to be passed along the request handlers chain.Added in version 3.10.
QgsServerApiContext(apiRootPath: str, request:
QgsServerRequest
, response:QgsServerResponse
, project:QgsProject
, serverInterface:QgsServerInterface
)QgsServerApiContext
constructor- Parameters:
apiRootPath – is the API root path, this information is used by the handlers to build the href links to the resources and to the HTML templates.
request – the incoming request
response – the response
project – the project (might be NULL)
serverInterface – the server interface
QgsServerApiContext(
QgsServerApiContext
)Methods
Returns the API root path
Returns the handler component of the URL path, i.e. the part of the path that comes after the API path.
Returns the initial part of the incoming request URL path that matches the API root path.
Returns the (possibly NULL) project
Returns the server request object
Returns the server response object
Returns the server interface
Sets the project to
project
Sets context request to
request
- apiRootPath(self) str ¶
Returns the API root path
- Return type:
str
- handlerPath(self) str ¶
Returns the handler component of the URL path, i.e. the part of the path that comes after the API path.
Added in version 3.22.
- Return type:
str
- matchedPath(self) str ¶
Returns the initial part of the incoming request URL path that matches the API root path. If there is no match returns an empty string (it should never happen).
I.e. for an API with root path “/wfs3” and an incoming request “https://www.qgis.org/services/wfs3/collections” this method will return “/resources/wfs3”
- Return type:
str
- project(self) QgsProject ¶
Returns the (possibly NULL) project
See also
- Return type:
- request(self) QgsServerRequest ¶
Returns the server request object
- Return type:
- response(self) QgsServerResponse ¶
Returns the server response object
- Return type:
- serverInterface(self) QgsServerInterface ¶
Returns the server interface
- Return type:
- setProject(self, project: QgsProject)¶
Sets the project to
project
See also
- Parameters:
project (QgsProject)
- setRequest(self, request: QgsServerRequest)¶
Sets context request to
request
- Parameters:
request (QgsServerRequest)