25 QMap<QgsServerOgcApi::ContentType, QStringList> QgsServerOgcApi::sContentTypeMime = [ ]() -> QMap<QgsServerOgcApi::ContentType, QStringList>
    27   QMap<QgsServerOgcApi::ContentType, QStringList> map;
    28   map[QgsServerOgcApi::ContentType::JSON] = QStringList { QStringLiteral( 
"application/json" ) };
    29   map[QgsServerOgcApi::ContentType::GEOJSON] = QStringList {
    30     QStringLiteral( 
"application/geo+json" ),
    31     QStringLiteral( 
"application/vnd.geo+json" ),
    32     QStringLiteral( 
"application/geojson" )
    34   map[QgsServerOgcApi::ContentType::HTML] = QStringList { QStringLiteral( 
"text/html" ) };
    35   map[QgsServerOgcApi::ContentType::OPENAPI3] = QStringList { QStringLiteral( 
"application/openapi+json;version=3.0" ) };
    39 QHash<QgsServerOgcApi::ContentType, QList<QgsServerOgcApi::ContentType>> QgsServerOgcApi::sContentTypeAliases = [ ]() -> QHash<ContentType, QList<ContentType>>
    41   QHash<QgsServerOgcApi::ContentType, QList<QgsServerOgcApi::ContentType>> map;
    42   map[ContentType::JSON] = { QgsServerOgcApi::ContentType::GEOJSON, QgsServerOgcApi::ContentType::OPENAPI3 };
    49   mRootPath( rootPath ),
    51   mDescription( description ),
    64   std::shared_ptr<QgsServerOgcApiHandler> hp( handler );
    65   mHandlers.emplace_back( std::move( hp ) );
    70   return url.adjusted( QUrl::StripTrailingSlash | QUrl::NormalizePathSegments );
    78   auto hasMatch { 
false };
    79   for ( 
const auto &h : mHandlers )
    82     if ( h->path().match( path ).hasMatch() )
    90         h->handleRequest( context );
    92       catch ( json::exception &ex )
   108   return sContentTypeMime;
   113   return sContentTypeAliases;
   118   static QMetaEnum metaEnum = QMetaEnum::fromType<QgsServerOgcApi::Rel>();
   119   std::string val { metaEnum.valueToKey( rel ) };
   120   std::replace( val.begin(), val.end(), 
'_', 
'-' );
   126   static QMetaEnum metaEnum = QMetaEnum::fromType<ContentType>();
   127   QString result { metaEnum.valueToKey( ct ) };
   128   return result.replace( 
'_', 
'-' );
   133   static QMetaEnum metaEnum = QMetaEnum::fromType<ContentType>();
   134   return metaEnum.valueToKey( ct );
   144   const QString exts = QString::fromStdString( extension );
   149     const auto constValues = it.value();
   150     for ( 
const auto &value : constValues )
   152       if ( value.contains( exts, Qt::CaseSensitivity::CaseInsensitive ) )
   159   QgsMessageLog::logMessage( QStringLiteral( 
"Content type for extension %1 not found! Returning default (JSON)" ).arg( exts ),
   160                              QStringLiteral( 
"Server" ),
   162   return QgsServerOgcApi::ContentType::JSON;
   167   if ( ! sContentTypeMime.contains( contentType ) )
   171   return sContentTypeMime.value( contentType ).first().toStdString();
 Server generic API endpoint abstract base class. 
const std::vector< std::shared_ptr< QgsServerOgcApiHandler > > handlers() const
Returns registered handlers. 
static QString contentTypeToString(const QgsServerOgcApi::ContentType &ct)
Returns the string representation of a ct (Content-Type) attribute. 
void registerHandler(Args... args)
Registers an OGC API handler passing Args to the constructor. 
The QgsServerOgcApiHandler abstract class represents a OGC API handler to be registered in QgsServerO...
static const QHash< QgsServerOgcApi::ContentType, QList< QgsServerOgcApi::ContentType > > contentTypeAliases()
Returns contenType specializations (e.g. 
static std::string relToString(const QgsServerOgcApi::Rel &rel)
Returns the string representation of rel attribute. 
static QgsServerOgcApi::ContentType contenTypeFromExtension(const std::string &extension)
Returns the Content-Type value corresponding to extension. 
Internal server error API exception. 
static const QMap< QgsServerOgcApi::ContentType, QStringList > contentTypeMimes()
Returns a map of contentType => list of mime types. 
ContentType
Media types used for content negotiation, insert more specific first. 
QgsServerOgcApi(QgsServerInterface *serverIface, const QString &rootPath, const QString &name, const QString &description=QString(), const QString &version=QString())
QgsServerOgcApi constructor. 
static std::string contentTypeToStdString(const QgsServerOgcApi::ContentType &ct)
Returns the string representation of a ct (Content-Type) attribute. 
static std::string mimeType(const QgsServerOgcApi::ContentType &contentType)
Returns the mime-type for the contentType or an empty string if not found. 
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary). 
static QUrl sanitizeUrl(const QUrl &url)
Returns a sanitized url with extra slashes removed. 
The QgsServerApiContext class encapsulates the resources for a particular client request: the request...
Bad request error API exception. 
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins...
virtual void executeRequest(const QgsServerApiContext &context) const override SIP_THROW(QgsServerApiBadRequestException)
Executes a request by passing the given context to the API handlers. 
static QString contentTypeToExtension(const QgsServerOgcApi::ContentType &ct)
Returns the file extension for a ct (Content-Type). 
~QgsServerOgcApi() override
const QgsServerRequest * request() const
Returns the server request object.