Class: QgsServerApiContext

class qgis.server.QgsServerApiContext(apiRootPath: str, request: QgsServerRequest, response: QgsServerResponse, project: QgsProject, serverInterface: QgsServerInterface)

Bases: sip.wrapper

QgsServerApiContext constructor

Parameters
  • apiRootPath (str) – 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 (QgsServerRequest) – the incoming request

  • response (QgsServerResponse) – the response

  • project (QgsProject) – the project (might be NULL)

  • serverInterface (QgsServerInterface) – the server interface

QgsServerApiContext(QgsServerApiContext)

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.

Methods

apiRootPath

Returns the API root path

matchedPath

Returns the initial part of the incoming request URL path that matches the API root path.

project

Returns the (possibly NULL) project

request

Returns the server request object

response

Returns the server response object

serverInterface

Returns the server interface

setProject

Sets the project to project

setRequest

Sets context request to request

apiRootPath(self) → str

Returns the API root path

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

setProject()

Return type

QgsProject

request(self) → QgsServerRequest

Returns the server request object

Return type

QgsServerRequest

response(self) → QgsServerResponse

Returns the server response object

Return type

QgsServerResponse

serverInterface(self) → QgsServerInterface

Returns the server interface

Return type

QgsServerInterface

setProject(self, project: QgsProject)

Sets the project to project

See also

project()

Parameters

project (QgsProject) –

setRequest(self, request: QgsServerRequest)

Sets context request to request

Parameters

request (QgsServerRequest) –