diff options
author | joshualitt <joshualitt@chromium.org> | 2016-02-25 11:28:18 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-25 11:28:18 -0800 |
commit | 3854f11ce35857ccb6dbf8bb09bef9252543090f (patch) | |
tree | 1adacad85f2835c68ea50136bbad3084a3da40ea /tools/skiaserve/urlhandlers | |
parent | f57b3a6e4a002caf01378832cbd756c6c163a783 (diff) |
Move urlhandlers out of skiaserve.cpp
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1737643003
Review URL: https://codereview.chromium.org/1737643003
Diffstat (limited to 'tools/skiaserve/urlhandlers')
-rw-r--r-- | tools/skiaserve/urlhandlers/BreakHandler.cpp | 99 | ||||
-rw-r--r-- | tools/skiaserve/urlhandlers/ClipAlphaHandler.cpp | 38 | ||||
-rw-r--r-- | tools/skiaserve/urlhandlers/CmdHandler.cpp | 61 | ||||
-rw-r--r-- | tools/skiaserve/urlhandlers/DataHandler.cpp | 40 | ||||
-rw-r--r-- | tools/skiaserve/urlhandlers/DownloadHandler.cpp | 51 | ||||
-rw-r--r-- | tools/skiaserve/urlhandlers/EnableGPUHandler.cpp | 48 | ||||
-rw-r--r-- | tools/skiaserve/urlhandlers/ImgHandler.cpp | 43 | ||||
-rw-r--r-- | tools/skiaserve/urlhandlers/InfoHandler.cpp | 61 | ||||
-rw-r--r-- | tools/skiaserve/urlhandlers/PostHandler.cpp | 84 | ||||
-rw-r--r-- | tools/skiaserve/urlhandlers/RootHandler.cpp | 26 | ||||
-rw-r--r-- | tools/skiaserve/urlhandlers/UrlHandler.h | 111 |
11 files changed, 662 insertions, 0 deletions
diff --git a/tools/skiaserve/urlhandlers/BreakHandler.cpp b/tools/skiaserve/urlhandlers/BreakHandler.cpp new file mode 100644 index 0000000000..9e01c0f509 --- /dev/null +++ b/tools/skiaserve/urlhandlers/BreakHandler.cpp @@ -0,0 +1,99 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "UrlHandler.h" + +#include "microhttpd.h" +#include "../Request.h" +#include "../Response.h" + +using namespace Response; + +bool BreakHandler::canHandle(const char* method, const char* url) { + static const char* kBasePath = "/break"; + return 0 == strcmp(method, MHD_HTTP_METHOD_GET) && + 0 == strncmp(url, kBasePath, strlen(kBasePath)); +} + +SkColor BreakHandler::GetPixel(Request* request, int x, int y) { + SkCanvas* canvas = request->getCanvas(); + canvas->flush(); + SkAutoTDelete<SkBitmap> bitmap(request->getBitmapFromCanvas(canvas)); + SkASSERT(bitmap); + bitmap->lockPixels(); + uint8_t* start = ((uint8_t*) bitmap->getPixels()) + (y * Request::kImageWidth + x) * 4; + SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]); + bitmap->unlockPixels(); + return result; +} + + +int BreakHandler::handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) { + SkTArray<SkString> commands; + SkStrSplit(url, "/", &commands); + + if (!request->fPicture.get() || commands.count() != 4) { + return MHD_NO; + } + + // /break/<n>/<x>/<y> + int n; + sscanf(commands[1].c_str(), "%d", &n); + int x; + sscanf(commands[2].c_str(), "%d", &x); + int y; + sscanf(commands[3].c_str(), "%d", &y); + + int count = request->fDebugCanvas->getSize(); + SkASSERT(n < count); + + SkCanvas* canvas = request->getCanvas(); + canvas->clear(SK_ColorWHITE); + int saveCount = canvas->save(); + for (int i = 0; i <= n; ++i) { + request->fDebugCanvas->getDrawCommandAt(i)->execute(canvas); + } + SkColor target = GetPixel(request, x, y); + Json::Value response(Json::objectValue); + Json::Value startColor(Json::arrayValue); + startColor.append(Json::Value(SkColorGetR(target))); + startColor.append(Json::Value(SkColorGetG(target))); + startColor.append(Json::Value(SkColorGetB(target))); + startColor.append(Json::Value(SkColorGetA(target))); + response["startColor"] = startColor; + response["endColor"] = startColor; + response["endOp"] = Json::Value(n); + for (int i = n + 1; i < n + count; ++i) { + int index = i % count; + if (index == 0) { + // reset canvas for wraparound + canvas->restoreToCount(saveCount); + canvas->clear(SK_ColorWHITE); + saveCount = canvas->save(); + } + request->fDebugCanvas->getDrawCommandAt(index)->execute(canvas); + SkColor current = GetPixel(request, x, y); + if (current != target) { + Json::Value endColor(Json::arrayValue); + endColor.append(Json::Value(SkColorGetR(current))); + endColor.append(Json::Value(SkColorGetG(current))); + endColor.append(Json::Value(SkColorGetB(current))); + endColor.append(Json::Value(SkColorGetA(current))); + response["endColor"] = endColor; + response["endOp"] = Json::Value(index); + break; + } + } + canvas->restoreToCount(saveCount); + SkDynamicMemoryWStream stream; + stream.writeText(Json::FastWriter().write(response).c_str()); + SkAutoTUnref<SkData> data(stream.copyToData()); + return SendData(connection, data, "application/json"); +} + diff --git a/tools/skiaserve/urlhandlers/ClipAlphaHandler.cpp b/tools/skiaserve/urlhandlers/ClipAlphaHandler.cpp new file mode 100644 index 0000000000..4d66fc9958 --- /dev/null +++ b/tools/skiaserve/urlhandlers/ClipAlphaHandler.cpp @@ -0,0 +1,38 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "UrlHandler.h" + +#include "microhttpd.h" +#include "../Request.h" +#include "../Response.h" + +using namespace Response; + +bool ClipAlphaHandler::canHandle(const char* method, const char* url) { + static const char* kBasePath = "/clipAlpha/"; + return 0 == strcmp(method, MHD_HTTP_METHOD_POST) && + 0 == strncmp(url, kBasePath, strlen(kBasePath)); +} + +int ClipAlphaHandler::handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) { + SkTArray<SkString> commands; + SkStrSplit(url, "/", &commands); + + if (!request->fPicture.get() || commands.count() != 2) { + return MHD_NO; + } + + int alpha; + sscanf(commands[1].c_str(), "%d", &alpha); + + request->fDebugCanvas->setClipVizColor(SkColorSetARGB(alpha, 0, 0, 0)); + return SendOK(connection); +} + diff --git a/tools/skiaserve/urlhandlers/CmdHandler.cpp b/tools/skiaserve/urlhandlers/CmdHandler.cpp new file mode 100644 index 0000000000..c741eb9a43 --- /dev/null +++ b/tools/skiaserve/urlhandlers/CmdHandler.cpp @@ -0,0 +1,61 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "UrlHandler.h" + +#include "microhttpd.h" +#include "../Request.h" +#include "../Response.h" + +using namespace Response; + +bool CmdHandler::canHandle(const char* method, const char* url) { + const char* kBasePath = "/cmd"; + return 0 == strncmp(url, kBasePath, strlen(kBasePath)); +} + +int CmdHandler::handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) { + SkTArray<SkString> commands; + SkStrSplit(url, "/", &commands); + + if (!request->fPicture.get() || commands.count() > 3) { + return MHD_NO; + } + + // /cmd or /cmd/N + if (0 == strcmp(method, MHD_HTTP_METHOD_GET)) { + int n; + if (commands.count() == 1) { + n = request->fDebugCanvas->getSize() - 1; + } else { + sscanf(commands[1].c_str(), "%d", &n); + } + return SendJSON(connection, request, n); + } + + // /cmd/N, for now only delete supported + if (commands.count() == 2 && 0 == strcmp(method, MHD_HTTP_METHOD_DELETE)) { + int n; + sscanf(commands[1].c_str(), "%d", &n); + request->fDebugCanvas->deleteDrawCommandAt(n); + return SendOK(connection); + } + + // /cmd/N/[0|1] + if (commands.count() == 3 && 0 == strcmp(method, MHD_HTTP_METHOD_POST)) { + int n, toggle; + sscanf(commands[1].c_str(), "%d", &n); + sscanf(commands[2].c_str(), "%d", &toggle); + request->fDebugCanvas->toggleCommand(n, toggle); + return SendOK(connection); + } + + return MHD_NO; +} + diff --git a/tools/skiaserve/urlhandlers/DataHandler.cpp b/tools/skiaserve/urlhandlers/DataHandler.cpp new file mode 100644 index 0000000000..adad99971f --- /dev/null +++ b/tools/skiaserve/urlhandlers/DataHandler.cpp @@ -0,0 +1,40 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "UrlHandler.h" + +#include "microhttpd.h" +#include "../Request.h" +#include "../Response.h" + +using namespace Response; + +bool DataHandler::canHandle(const char* method, const char* url) { + static const char* kBaseUrl = "/data"; + return 0 == strcmp(method, MHD_HTTP_METHOD_GET) && + 0 == strncmp(url, kBaseUrl, strlen(kBaseUrl)); +} + +int DataHandler::handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) { + SkTArray<SkString> commands; + SkStrSplit(url, "/", &commands); + + if (!request->fPicture.get() || commands.count() != 2) { + return MHD_NO; + } + + SkAutoTUnref<UrlDataManager::UrlData> urlData( + SkRef(request->fUrlDataManager.getDataFromUrl(SkString(url)))); + + if (urlData) { + return SendData(connection, urlData->fData.get(), urlData->fContentType.c_str()); + } + return MHD_NO; +} + diff --git a/tools/skiaserve/urlhandlers/DownloadHandler.cpp b/tools/skiaserve/urlhandlers/DownloadHandler.cpp new file mode 100644 index 0000000000..719a382494 --- /dev/null +++ b/tools/skiaserve/urlhandlers/DownloadHandler.cpp @@ -0,0 +1,51 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "UrlHandler.h" + +#include "microhttpd.h" +#include "SkPictureRecorder.h" +#include "SkPixelSerializer.h" +#include "../Request.h" +#include "../Response.h" + +using namespace Response; + +bool DownloadHandler::canHandle(const char* method, const char* url) { + return 0 == strcmp(method, MHD_HTTP_METHOD_GET) && + 0 == strcmp(url, "/download"); +} + +int DownloadHandler::handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) { + if (!request->fPicture.get()) { + return MHD_NO; + } + + // TODO move to a function + // Playback into picture recorder + SkPictureRecorder recorder; + SkCanvas* canvas = recorder.beginRecording(Request::kImageWidth, + Request::kImageHeight); + + request->fDebugCanvas->draw(canvas); + + SkAutoTUnref<SkPicture> picture(recorder.endRecording()); + + SkDynamicMemoryWStream outStream; + + SkAutoTUnref<SkPixelSerializer> serializer(SkImageEncoder::CreatePixelSerializer()); + picture->serialize(&outStream, serializer); + + SkAutoTUnref<SkData> data(outStream.copyToData()); + + // TODO fancier name handling + return SendData(connection, data, "application/octet-stream", true, + "attachment; filename=something.skp;"); +} + diff --git a/tools/skiaserve/urlhandlers/EnableGPUHandler.cpp b/tools/skiaserve/urlhandlers/EnableGPUHandler.cpp new file mode 100644 index 0000000000..2dc9bb60c6 --- /dev/null +++ b/tools/skiaserve/urlhandlers/EnableGPUHandler.cpp @@ -0,0 +1,48 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "UrlHandler.h" + +#include "microhttpd.h" +#include "../Request.h" +#include "../Response.h" + +using namespace Response; + +bool EnableGPUHandler::canHandle(const char* method, const char* url) { + static const char* kBasePath = "/enableGPU/"; + return 0 == strcmp(method, MHD_HTTP_METHOD_POST) && + 0 == strncmp(url, kBasePath, strlen(kBasePath)); +} + +int EnableGPUHandler::handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) { + SkTArray<SkString> commands; + SkStrSplit(url, "/", &commands); + + if (commands.count() != 2) { + return MHD_NO; + } + + int enable; + sscanf(commands[1].c_str(), "%d", &enable); + + if (enable) { + SkSurface* surface = request->createGPUSurface(); + if (surface) { + request->fSurface.reset(surface); + request->fGPUEnabled = true; + return SendOK(connection); + } + return SendError(connection, "Unable to create GPU surface"); + } + request->fSurface.reset(request->createCPUSurface()); + request->fGPUEnabled = false; + return SendOK(connection); +} + diff --git a/tools/skiaserve/urlhandlers/ImgHandler.cpp b/tools/skiaserve/urlhandlers/ImgHandler.cpp new file mode 100644 index 0000000000..68828267fb --- /dev/null +++ b/tools/skiaserve/urlhandlers/ImgHandler.cpp @@ -0,0 +1,43 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "UrlHandler.h" + +#include "microhttpd.h" +#include "../Request.h" +#include "../Response.h" + +using namespace Response; + +bool ImgHandler::canHandle(const char* method, const char* url) { + static const char* kBasePath = "/img"; + return 0 == strcmp(method, MHD_HTTP_METHOD_GET) && + 0 == strncmp(url, kBasePath, strlen(kBasePath)); +} + +int ImgHandler::handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) { + SkTArray<SkString> commands; + SkStrSplit(url, "/", &commands); + + if (!request->fPicture.get() || commands.count() > 2) { + return MHD_NO; + } + + int n; + // /img or /img/N + if (commands.count() == 1) { + n = request->fDebugCanvas->getSize() - 1; + } else { + sscanf(commands[1].c_str(), "%d", &n); + } + + SkAutoTUnref<SkData> data(request->drawToPng(n)); + return SendData(connection, data, "image/png"); +} + diff --git a/tools/skiaserve/urlhandlers/InfoHandler.cpp b/tools/skiaserve/urlhandlers/InfoHandler.cpp new file mode 100644 index 0000000000..16dbefb415 --- /dev/null +++ b/tools/skiaserve/urlhandlers/InfoHandler.cpp @@ -0,0 +1,61 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "UrlHandler.h" + +#include "microhttpd.h" +#include "SkJSONCanvas.h" +#include "../Request.h" +#include "../Response.h" + +using namespace Response; + +bool InfoHandler::canHandle(const char* method, const char* url) { + const char* kBaseName = "/info"; + return 0 == strcmp(method, MHD_HTTP_METHOD_GET) && + 0 == strncmp(url, kBaseName, strlen(kBaseName)); +} + +int InfoHandler::handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) { + SkTArray<SkString> commands; + SkStrSplit(url, "/", &commands); + + if (!request->fPicture.get() || commands.count() > 2) { + return MHD_NO; + } + + // drawTo + SkAutoTUnref<SkSurface> surface(request->createCPUSurface()); + SkCanvas* canvas = surface->getCanvas(); + + int n; + // /info or /info/N + if (commands.count() == 1) { + n = request->fDebugCanvas->getSize() - 1; + } else { + sscanf(commands[1].c_str(), "%d", &n); + } + + // TODO this is really slow and we should cache the matrix and clip + request->fDebugCanvas->drawTo(canvas, n); + + // make some json + SkMatrix vm = request->fDebugCanvas->getCurrentMatrix(); + SkIRect clip = request->fDebugCanvas->getCurrentClip(); + Json::Value info(Json::objectValue); + info["ViewMatrix"] = SkJSONCanvas::MakeMatrix(vm); + info["ClipRect"] = SkJSONCanvas::MakeIRect(clip); + + std::string json = Json::FastWriter().write(info); + + // We don't want the null terminator so strlen is correct + SkAutoTUnref<SkData> data(SkData::NewWithCopy(json.c_str(), strlen(json.c_str()))); + return SendData(connection, data, "application/json"); +} + diff --git a/tools/skiaserve/urlhandlers/PostHandler.cpp b/tools/skiaserve/urlhandlers/PostHandler.cpp new file mode 100644 index 0000000000..7cdbf295c6 --- /dev/null +++ b/tools/skiaserve/urlhandlers/PostHandler.cpp @@ -0,0 +1,84 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "UrlHandler.h" + +#include "microhttpd.h" +#include "../Request.h" +#include "../Response.h" + +using namespace Response; + +static const size_t kBufferSize = 1024; + +static int process_upload_data(void* cls, enum MHD_ValueKind kind, + const char* key, const char* filename, + const char* content_type, const char* transfer_encoding, + const char* data, uint64_t off, size_t size) { + struct UploadContext* uc = reinterpret_cast<UploadContext*>(cls); + + if (0 != size) { + uc->fStream.write(data, size); + } + return MHD_YES; +} + +bool PostHandler::canHandle(const char* method, const char* url) { + return 0 == strcmp(method, MHD_HTTP_METHOD_POST) && + 0 == strcmp(url, "/new"); +} + +int PostHandler::handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) { + UploadContext* uc = request->fUploadContext; + + // New connection + if (!uc) { + // TODO make this a method on request + uc = new UploadContext; + uc->connection = connection; + uc->fPostProcessor = MHD_create_post_processor(connection, kBufferSize, + &process_upload_data, uc); + SkASSERT(uc->fPostProcessor); + + request->fUploadContext = uc; + return MHD_YES; + } + + // in process upload + if (0 != *upload_data_size) { + SkASSERT(uc->fPostProcessor); + MHD_post_process(uc->fPostProcessor, upload_data, *upload_data_size); + *upload_data_size = 0; + return MHD_YES; + } + + // end of upload + MHD_destroy_post_processor(uc->fPostProcessor); + uc->fPostProcessor = nullptr; + + // parse picture from stream + request->fPicture.reset( + SkPicture::CreateFromStream(request->fUploadContext->fStream.detachAsStream())); + if (!request->fPicture.get()) { + fprintf(stderr, "Could not create picture from stream.\n"); + return MHD_NO; + } + + // pour picture into debug canvas + request->fDebugCanvas.reset(new SkDebugCanvas(Request::kImageWidth, + Request::kImageHeight)); + request->fDebugCanvas->drawPicture(request->fPicture); + + // clear upload context + delete request->fUploadContext; + request->fUploadContext = nullptr; + + return SendTemplate(connection, true, "/"); +} + diff --git a/tools/skiaserve/urlhandlers/RootHandler.cpp b/tools/skiaserve/urlhandlers/RootHandler.cpp new file mode 100644 index 0000000000..03b87f3b82 --- /dev/null +++ b/tools/skiaserve/urlhandlers/RootHandler.cpp @@ -0,0 +1,26 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "UrlHandler.h" + +#include "microhttpd.h" +#include "../Request.h" +#include "../Response.h" + +using namespace Response; + +bool RootHandler::canHandle(const char* method, const char* url) { + return 0 == strcmp(method, MHD_HTTP_METHOD_GET) && + 0 == strcmp(url, "/"); +} + +int RootHandler::handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) { + return SendTemplate(connection); +} + diff --git a/tools/skiaserve/urlhandlers/UrlHandler.h b/tools/skiaserve/urlhandlers/UrlHandler.h new file mode 100644 index 0000000000..9eee35f489 --- /dev/null +++ b/tools/skiaserve/urlhandlers/UrlHandler.h @@ -0,0 +1,111 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkColor.h" + +struct MHD_Connection; +struct Request; + +class UrlHandler { +public: + virtual ~UrlHandler() {} + virtual bool canHandle(const char* method, const char* url) = 0; + virtual int handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) = 0; +}; + +class CmdHandler : public UrlHandler { +public: + bool canHandle(const char* method, const char* url) override; + int handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) override; +}; + +class ImgHandler : public UrlHandler { +public: + bool canHandle(const char* method, const char* url) override; + int handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) override; +}; + +class BreakHandler : public UrlHandler { +public: + bool canHandle(const char* method, const char* url) override; + int handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) override; +private: + static SkColor GetPixel(Request* request, int x, int y); +}; + +/** + Updates the clip visualization alpha. On all subsequent /img requests, the clip will be drawn in + black with the specified alpha. 0 = no visible clip, 255 = fully opaque clip. + */ +class ClipAlphaHandler : public UrlHandler { +public: + bool canHandle(const char* method, const char* url) override; + int handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) override; +}; + +/** + Controls whether GPU rendering is enabled. Posting to /enableGPU/1 turns GPU on, /enableGPU/0 + disables it. + */ +class EnableGPUHandler : public UrlHandler { +public: + bool canHandle(const char* method, const char* url) override; + int handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) override; +}; + +class PostHandler : public UrlHandler { +public: + bool canHandle(const char* method, const char* url) override; + int handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) override; +}; + +class DownloadHandler : public UrlHandler { +public: + bool canHandle(const char* method, const char* url) override; + int handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) override; +}; + +class InfoHandler : public UrlHandler { +public: + bool canHandle(const char* method, const char* url) override; + int handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) override; +}; + +class DataHandler : public UrlHandler { +public: + bool canHandle(const char* method, const char* url) override; + int handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) override; +}; + +class RootHandler : public UrlHandler { +public: + bool canHandle(const char* method, const char* url) override; + int handle(Request* request, MHD_Connection* connection, + const char* url, const char* method, + const char* upload_data, size_t* upload_data_size) override; +}; + |