QHttpEngine 1.0.1
Simple and secure HTTP server for Qt applications
Loading...
Searching...
No Matches
QHttpEngine::FilesystemHandler Class Reference

Handler for filesystem requests More...

#include <qhttpengine/filesystemhandler.h>

Inheritance diagram for QHttpEngine::FilesystemHandler:
QHttpEngine::Handler

Public Member Functions

 FilesystemHandler (const QString &documentRoot, QObject *parent=0)
 Create a new filesystem handler from the specified directory.
 FilesystemHandler (QObject *parent=0)
 Create a new filesystem handler.
void setDocumentRoot (const QString &documentRoot)
 Set the document root.
Public Member Functions inherited from QHttpEngine::Handler
 Handler (QObject *parent=0)
 Base constructor for a handler.
void addMiddleware (Middleware *middleware)
 Add middleware to the handler.
void addRedirect (const QRegExp &pattern, const QString &path)
 Add a redirect for a specific pattern.
void addSubHandler (const QRegExp &pattern, Handler *handler)
 Add a handler for a specific pattern.
void route (Socket *socket, const QString &path)
 Route an incoming request.

Protected Member Functions

virtual void process (Socket *socket, const QString &path)
 Reimplementation of [Handler::process()](QHttpEngine::Handler::process)

Friends

class FilesystemHandlerPrivate

Detailed Description

This handler responds to requests for resources on a local filesystem. The constructor is provided with a path to the root directory, which will be used to resolve all paths. The following example creates a handler that serves files from the /var/www directory:

QHttpEngine::FilesystemHandler handler("/var/www");
Handler for filesystem requests
Definition filesystemhandler.h:52

Requests for resources outside the root will be ignored. The document root can be modified after initialization. It is possible to use a resource directory for the document root.

Member Function Documentation

◆ process()

virtual void QHttpEngine::FilesystemHandler::process ( Socket * socket,
const QString & path )
protectedvirtual

Reimplemented from QHttpEngine::Handler.

◆ setDocumentRoot()

void QHttpEngine::FilesystemHandler::setDocumentRoot ( const QString & documentRoot)

The root path provided is used to resolve each of the requests when they are received.


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