handlers: Introduce HandlerVersion to return the verison string
This commit is contained in:
szülő
c9dc3416d7
commit
7a2f15cabe
@ -33,7 +33,7 @@ SOFTWARE.
|
|||||||
#include "handlerhistory.h"
|
#include "handlerhistory.h"
|
||||||
#include "handlerpagedelete.h"
|
#include "handlerpagedelete.h"
|
||||||
#include "handlerusersettings.h"
|
#include "handlerusersettings.h"
|
||||||
|
#include "handlerversion.h"
|
||||||
std::unique_ptr<Handler> HandlerFactory::createHandler(const std::string &action, Session &userSession)
|
std::unique_ptr<Handler> HandlerFactory::createHandler(const std::string &action, Session &userSession)
|
||||||
{
|
{
|
||||||
if(action == "" || action == "index")
|
if(action == "" || action == "index")
|
||||||
@ -80,6 +80,10 @@ std::unique_ptr<Handler> HandlerFactory::createHandler(const std::string &action
|
|||||||
{
|
{
|
||||||
return produce<HandlerUserSettings>(userSession);
|
return produce<HandlerUserSettings>(userSession);
|
||||||
}
|
}
|
||||||
|
if(action == "version")
|
||||||
|
{
|
||||||
|
return produce<HandlerVersion>(userSession);
|
||||||
|
}
|
||||||
|
|
||||||
return produce<HandlerInvalidAction>(userSession);
|
return produce<HandlerInvalidAction>(userSession);
|
||||||
}
|
}
|
||||||
|
9
handlers/handlerversion.cpp
Normal file
9
handlers/handlerversion.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include "handlerversion.h"
|
||||||
|
#include "../version.h"
|
||||||
|
Response HandlerVersion::handleRequest(const Request &r)
|
||||||
|
{
|
||||||
|
Response response;
|
||||||
|
response.setContentType("text/plain");
|
||||||
|
response.setBody(get_version_string());
|
||||||
|
return response;
|
||||||
|
}
|
18
handlers/handlerversion.h
Normal file
18
handlers/handlerversion.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef HANDLERVERSION_H
|
||||||
|
#define HANDLERVERSION_H
|
||||||
|
#include "handler.h"
|
||||||
|
class HandlerVersion : public Handler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using Handler::Handler;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Response handleRequest(const Request &r) override;
|
||||||
|
|
||||||
|
bool canAccess(const Permissions &perms) override
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // HANDLERVERSION_H
|
Betöltés…
Reference in New Issue
Block a user