QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsServerStaticHandler Class Reference

The QgsServerStaticHandler class serves static files from the static path (resources/server/api/wfs3/static) More...

#include <qgsserverstatichandler.h>

Inheritance diagram for QgsServerStaticHandler:
Inheritance graph
[legend]

Public Member Functions

 QgsServerStaticHandler (const QString &pathRegExp=QStringLiteral("/static/(?<staticFilePath>.*)$"), const QString &staticPathSuffix=QString())
 Creates QgsServerStaticHandler.
 
std::string description () const override
 Description.
 
void handleRequest (const QgsServerApiContext &context) const override
 Handles the request within its context.
 
std::string linkTitle () const override
 Title for the handler link.
 
QgsServerOgcApi::Rel linkType () const override
 Main role for the resource link.
 
std::string operationId () const override
 Returns the operation id for template file names and other internal references.
 
QRegularExpression path () const override
 URL pattern for this handler, named capture group are automatically extracted and returned by values()
 
std::string summary () const override
 Summary.
 
- Public Member Functions inherited from QgsServerOgcApiHandler
virtual ~QgsServerOgcApiHandler ()
 
QString contentTypeForAccept (const QString &accept) const
 Looks for the first ContentType match in the accept header and returns its mime type, returns an empty string if there are not matches.
 
QgsServerOgcApi::ContentType contentTypeFromRequest (const QgsServerRequest *request) const
 Returns the content type from the request.
 
QList< QgsServerOgcApi::ContentTypecontentTypes () const
 Returns the list of content types this handler can serve, default to JSON and HTML.
 
virtual QgsServerOgcApi::ContentType defaultContentType () const
 Returns the default response content type in case the client did not specifically ask for any particular content type.
 
std::string href (const QgsServerApiContext &context, const QString &extraPath=QString(), const QString &extension=QString()) const
 Returns an URL to self, to be used for links to the current resources and as a base for constructing links to sub-resources.
 
void htmlDump (const json &data, const QgsServerApiContext &context) const
 Writes data as HTML to the response stream in context using a template.
 
void jsonDump (json &data, const QgsServerApiContext &context, const QString &contentType=QStringLiteral("application/json")) const
 Writes data to the context response stream as JSON (indented if debug is active), an optional contentType can be specified.
 
json jsonTags () const
 Returns tags as JSON.
 
QgsVectorLayerlayerFromContext (const QgsServerApiContext &context) const
 Returns a vector layer instance from the "collectionId" parameter of the path in the given context, requires a valid project instance in the context.
 
json link (const QgsServerApiContext &context, const QgsServerOgcApi::Rel &linkType=QgsServerOgcApi::Rel::self, const QgsServerOgcApi::ContentType contentType=QgsServerOgcApi::ContentType::JSON, const std::string &title="") const
 Builds and returns a link to the resource.
 
json links (const QgsServerApiContext &context) const
 Returns all the links for the given request context.
 
virtual QList< QgsServerQueryStringParameterparameters (const QgsServerApiContext &context) const
 Returns a list of query string parameters.
 
virtual json schema (const QgsServerApiContext &context) const
 Returns handler information from the context for the OPENAPI description (id, description and other metadata) as JSON.
 
virtual const QString staticPath (const QgsServerApiContext &context) const
 Returns the absolute path to the base directory where static resources for this handler are stored in the given context.
 
virtual QStringList tags () const
 Tags.
 
virtual const QString templatePath (const QgsServerApiContext &context) const
 Returns the HTML template path for the handler in the given context.
 
virtual QVariantMap values (const QgsServerApiContext &context) const
 Analyzes the incoming request context and returns the validated parameter map, throws QgsServerApiBadRequestError in case of errors.
 
void write (json &data, const QgsServerApiContext &context, const json &htmlMetadata=nullptr) const
 Writes data to the context response stream, content-type is calculated from the context request, optional htmlMetadata for the HTML templates can be specified and will be added as "metadata" to the HTML template variables.
 
void write (QVariant &data, const QgsServerApiContext &context, const QVariantMap &htmlMetadata=QVariantMap()) const
 Writes data to the context response stream, content-type is calculated from the context request, optional htmlMetadata for the HTML templates can be specified and will be added as "metadata" to the HTML template variables.
 

Additional Inherited Members

- Static Public Member Functions inherited from QgsServerOgcApiHandler
static json defaultResponse ()
 Returns the defaultResponse as JSON.
 
static QgsVectorLayerlayerFromCollectionId (const QgsServerApiContext &context, const QString &collectionId)
 Returns a vector layer from the collectionId in the given context.
 
static QString parentLink (const QUrl &url, int levels=1)
 Returns a link to the parent page up to levels in the HTML hierarchy from the given url, MAP query argument is preserved.
 
- Protected Member Functions inherited from QgsServerOgcApiHandler
void setContentTypes (const QList< QgsServerOgcApi::ContentType > &contentTypes)
 Set the content types to contentTypes.
 
void setContentTypesInt (const QList< int > &contentTypes)
 Set the content types to contentTypes.
 

Detailed Description

The QgsServerStaticHandler class serves static files from the static path (resources/server/api/wfs3/static)

See also
QgsServerOgcApiHandler::staticPath()
Since
QGIS 3.16

Definition at line 28 of file qgsserverstatichandler.h.

Constructor & Destructor Documentation

◆ QgsServerStaticHandler()

QgsServerStaticHandler::QgsServerStaticHandler ( const QString &  pathRegExp = QStringLiteral( "/static/(?<staticFilePath>.*)$" ),
const QString &  staticPathSuffix = QString( ) 
)

Creates QgsServerStaticHandler.

Parameters
pathRegExpoptional regular expression to capture static file names, defaults to "/static/(?<staticFilePath>.*)$", note that the file path is captured in a named group "staticFilePath"
staticPathSuffixoptional path suffix to use when static files are stored in a subdirectory of the default staticPath()
See also
QgsServerOgcApiHandler::staticPath()

Definition at line 24 of file qgsserverstatichandler.cpp.

Member Function Documentation

◆ description()

std::string QgsServerStaticHandler::description ( ) const
inlineoverridevirtual

Description.

Implements QgsServerOgcApiHandler.

Definition at line 47 of file qgsserverstatichandler.h.

◆ handleRequest()

void QgsServerStaticHandler::handleRequest ( const QgsServerApiContext context) const
overridevirtual

Handles the request within its context.

Subclasses must implement this methods, and call validate() to extract validated parameters from the request.

Exceptions
QgsServerApiBadRequestErrorif the method encounters any error

Reimplemented from QgsServerOgcApiHandler.

Definition at line 31 of file qgsserverstatichandler.cpp.

◆ linkTitle()

std::string QgsServerStaticHandler::linkTitle ( ) const
inlineoverridevirtual

Title for the handler link.

Implements QgsServerOgcApiHandler.

Definition at line 48 of file qgsserverstatichandler.h.

◆ linkType()

QgsServerOgcApi::Rel QgsServerStaticHandler::linkType ( ) const
inlineoverridevirtual

Main role for the resource link.

Implements QgsServerOgcApiHandler.

Definition at line 49 of file qgsserverstatichandler.h.

◆ operationId()

std::string QgsServerStaticHandler::operationId ( ) const
inlineoverridevirtual

Returns the operation id for template file names and other internal references.

Implements QgsServerOgcApiHandler.

Definition at line 45 of file qgsserverstatichandler.h.

◆ path()

QRegularExpression QgsServerStaticHandler::path ( ) const
inlineoverridevirtual

URL pattern for this handler, named capture group are automatically extracted and returned by values()

Example: "/handlername/(?P<code1>\d{2})/items" will capture "code1" as a named parameter.

See also
values()

Implements QgsServerOgcApiHandler.

Definition at line 44 of file qgsserverstatichandler.h.

◆ summary()

std::string QgsServerStaticHandler::summary ( ) const
inlineoverridevirtual

Summary.

Implements QgsServerOgcApiHandler.

Definition at line 46 of file qgsserverstatichandler.h.


The documentation for this class was generated from the following files: