mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
added new web controller for knowing the version of the web api
This commit is contained in:
parent
09e8062a9a
commit
1009b84363
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
#include "console_ui_library_creator.h"
|
#include "console_ui_library_creator.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include "QsLog.h"
|
#include "QsLog.h"
|
||||||
#include "QsLogDest.h"
|
#include "QsLogDest.h"
|
||||||
|
|
||||||
@ -118,7 +120,7 @@ int main( int argc, char ** argv )
|
|||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
parser.setApplicationDescription(QCoreApplication::tr("\nYACReaderLibraryServer is the headless (no gui) version of YACReaderLibrary"));
|
parser.setApplicationDescription(QCoreApplication::tr("\nYACReaderLibraryServer is the headless (no gui) version of YACReaderLibrary"));
|
||||||
parser.addHelpOption();
|
parser.addHelpOption();
|
||||||
parser.addVersionOption();
|
const QCommandLineOption versionOption = parser.addVersionOption();
|
||||||
parser.addPositionalArgument("command", "The command to execute. [start, create-library, update-library, add-library, remove-library, list-libraries]");
|
parser.addPositionalArgument("command", "The command to execute. [start, create-library, update-library, add-library, remove-library, list-libraries]");
|
||||||
|
|
||||||
parser.parse(QCoreApplication::arguments());
|
parser.parse(QCoreApplication::arguments());
|
||||||
@ -126,6 +128,13 @@ int main( int argc, char ** argv )
|
|||||||
const QStringList args = parser.positionalArguments();
|
const QStringList args = parser.positionalArguments();
|
||||||
const QString command = args.isEmpty() ? QString() : args.first();
|
const QString command = args.isEmpty() ? QString() : args.first();
|
||||||
|
|
||||||
|
if(parser.isSet(versionOption))
|
||||||
|
{
|
||||||
|
qout << "YACReaderLibraryServer" << " " << VERSION << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(command == "start")
|
if(command == "start")
|
||||||
{
|
{
|
||||||
QString destLog = YACReader::getSettingsPath()+"/yacreaderlibrary.log";
|
QString destLog = YACReader::getSettingsPath()+"/yacreaderlibrary.log";
|
||||||
|
10
YACReaderLibrary/server/controllers/versioncontroller.cpp
Normal file
10
YACReaderLibrary/server/controllers/versioncontroller.cpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include "versioncontroller.h"
|
||||||
|
|
||||||
|
VersionController::VersionController() {}
|
||||||
|
|
||||||
|
void VersionController::service(HttpRequest& request, HttpResponse& response)
|
||||||
|
{
|
||||||
|
Q_UNUSED(request);
|
||||||
|
|
||||||
|
response.writeText(SERVER_VERSION_NUMBER,true);
|
||||||
|
}
|
21
YACReaderLibrary/server/controllers/versioncontroller.h
Normal file
21
YACReaderLibrary/server/controllers/versioncontroller.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef VERSIONCONTROLLER_H
|
||||||
|
#define VERSIONCONTROLLER_H
|
||||||
|
|
||||||
|
#include "httprequest.h"
|
||||||
|
#include "httpresponse.h"
|
||||||
|
#include "httprequesthandler.h"
|
||||||
|
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
|
class VersionController : public HttpRequestHandler {
|
||||||
|
Q_OBJECT
|
||||||
|
Q_DISABLE_COPY(VersionController);
|
||||||
|
public:
|
||||||
|
/** Constructor */
|
||||||
|
VersionController();
|
||||||
|
|
||||||
|
/** Generates the response */
|
||||||
|
void service(HttpRequest& request, HttpResponse& response);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VERSIONCONTROLLER_H
|
@ -22,6 +22,7 @@
|
|||||||
#include "controllers/errorcontroller.h"
|
#include "controllers/errorcontroller.h"
|
||||||
#include "controllers/comicdownloadinfocontroller.h"
|
#include "controllers/comicdownloadinfocontroller.h"
|
||||||
#include "controllers/synccontroller.h"
|
#include "controllers/synccontroller.h"
|
||||||
|
#include "controllers/versioncontroller.h"
|
||||||
|
|
||||||
#include "db_helper.h"
|
#include "db_helper.h"
|
||||||
#include "yacreader_libraries.h"
|
#include "yacreader_libraries.h"
|
||||||
@ -95,20 +96,21 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
|
|||||||
QByteArray path=request.getPath();
|
QByteArray path=request.getPath();
|
||||||
qDebug("RequestMapper: path=%s",path.data());
|
qDebug("RequestMapper: path=%s",path.data());
|
||||||
|
|
||||||
QRegExp folder("/library/.+/folder/[0-9]+/?");//get comic content
|
static const QRegExp folder("/library/.+/folder/[0-9]+/?");//get comic content
|
||||||
QRegExp folderInfo("/library/.+/folder/[0-9]+/info/?"); //get folder info
|
static const QRegExp folderInfo("/library/.+/folder/[0-9]+/info/?"); //get folder info
|
||||||
QRegExp comicDownloadInfo("/library/.+/comic/[0-9]+/?"); //get comic info (basic/download info)
|
static const QRegExp comicDownloadInfo("/library/.+/comic/[0-9]+/?"); //get comic info (basic/download info)
|
||||||
QRegExp comicFullInfo("/library/.+/comic/[0-9]+/info/?"); //get comic info (full info)
|
static const QRegExp comicFullInfo("/library/.+/comic/[0-9]+/info/?"); //get comic info (full info)
|
||||||
QRegExp comicOpen("/library/.+/comic/[0-9]+/remote/?"); //the server will open for reading the comic
|
static const QRegExp comicOpen("/library/.+/comic/[0-9]+/remote/?"); //the server will open for reading the comic
|
||||||
QRegExp comicUpdate("/library/.+/comic/[0-9]+/update/?"); //get comic info
|
static const QRegExp comicUpdate("/library/.+/comic/[0-9]+/update/?"); //get comic info
|
||||||
QRegExp comicClose("/library/.+/comic/[0-9]+/close/?"); //the server will close the comic and free memory
|
static const QRegExp comicClose("/library/.+/comic/[0-9]+/close/?"); //the server will close the comic and free memory
|
||||||
QRegExp cover("/library/.+/cover/[0-9a-f]+.jpg"); //get comic cover (navigation)
|
static const QRegExp cover("/library/.+/cover/[0-9a-f]+.jpg"); //get comic cover (navigation)
|
||||||
QRegExp comicPage("/library/.+/comic/[0-9]+/page/[0-9]+/?"); //get comic page
|
static const QRegExp comicPage("/library/.+/comic/[0-9]+/page/[0-9]+/?"); //get comic page
|
||||||
QRegExp comicPageRemote("/library/.+/comic/[0-9]+/page/[0-9]+/remote?"); //get comic page (remote reading)
|
static const QRegExp comicPageRemote("/library/.+/comic/[0-9]+/page/[0-9]+/remote?"); //get comic page (remote reading)
|
||||||
|
static const QRegExp serverVersion("/version/?");
|
||||||
|
|
||||||
QRegExp sync("/sync");
|
static const QRegExp sync("/sync");
|
||||||
|
|
||||||
QRegExp library("/library/([0-9]+)/.+"); //permite verificar que la biblioteca solicitada existe
|
static const QRegExp library("/library/([0-9]+)/.+"); //permite verificar que la biblioteca solicitada existe
|
||||||
|
|
||||||
path = QUrl::fromPercentEncoding(path).toUtf8();
|
path = QUrl::fromPercentEncoding(path).toUtf8();
|
||||||
|
|
||||||
@ -122,8 +124,14 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(sync.exactMatch(path))
|
if(serverVersion.exactMatch(path))
|
||||||
|
{
|
||||||
|
VersionController().service(request, response);
|
||||||
|
}
|
||||||
|
else if(sync.exactMatch(path))
|
||||||
|
{
|
||||||
SyncController().service(request, response);
|
SyncController().service(request, response);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//se comprueba que la sesión sea la correcta con el fin de evitar accesos no autorizados
|
//se comprueba que la sesión sea la correcta con el fin de evitar accesos no autorizados
|
||||||
|
@ -15,7 +15,9 @@ HEADERS += \
|
|||||||
$$PWD/controllers/covercontroller.h \
|
$$PWD/controllers/covercontroller.h \
|
||||||
$$PWD/controllers/updatecomiccontroller.h \
|
$$PWD/controllers/updatecomiccontroller.h \
|
||||||
$$PWD/controllers/comicdownloadinfocontroller.h \
|
$$PWD/controllers/comicdownloadinfocontroller.h \
|
||||||
$$PWD/controllers/synccontroller.h
|
$$PWD/controllers/synccontroller.h \
|
||||||
|
#v2
|
||||||
|
$$PWD/controllers/versioncontroller.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/static.cpp \
|
$$PWD/static.cpp \
|
||||||
@ -31,8 +33,12 @@ SOURCES += \
|
|||||||
$$PWD/controllers/covercontroller.cpp \
|
$$PWD/controllers/covercontroller.cpp \
|
||||||
$$PWD/controllers/updatecomiccontroller.cpp \
|
$$PWD/controllers/updatecomiccontroller.cpp \
|
||||||
$$PWD/controllers/comicdownloadinfocontroller.cpp \
|
$$PWD/controllers/comicdownloadinfocontroller.cpp \
|
||||||
$$PWD/controllers/synccontroller.cpp
|
$$PWD/controllers/synccontroller.cpp \
|
||||||
|
#v2
|
||||||
|
$$PWD/controllers/versioncontroller.cpp
|
||||||
|
|
||||||
include(lib/bfLogging/bfLogging.pri)
|
include(lib/bfLogging/bfLogging.pri)
|
||||||
include(lib/bfHttpServer/bfHttpServer.pri)
|
include(lib/bfHttpServer/bfHttpServer.pri)
|
||||||
include(lib/bfTemplateEngine/bfTemplateEngine.pri)
|
include(lib/bfTemplateEngine/bfTemplateEngine.pri)
|
||||||
|
|
||||||
|
DEFINES += SERVER_VERSION_NUMBER=\\\"2.0\\\"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user