From 3131fa0db3000fb5c944e3822361de6fe7bb1b82 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 6 Mar 2018 19:43:22 +0000 Subject: Add basic site setup --- site/custom.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 site/custom.cpp (limited to 'site/custom.cpp') diff --git a/site/custom.cpp b/site/custom.cpp new file mode 100644 index 0000000..35d0d40 --- /dev/null +++ b/site/custom.cpp @@ -0,0 +1,38 @@ +#include "icespider-routes-search.h" + +namespace MirrorSearch { + // Implementation classes. + + // Route name: download + // path: /download/{filename} + class download : public IceSpider::IRouteHandler { + public: + download(const IceSpider::Core * core) : + IceSpider::IRouteHandler(IceSpider::HttpMethod::GET, "/download/{filename}"), + prx0(core->getProxy()), + _pi_filename(1) + { + } + + void execute(IceSpider::IHttpRequest * request) const + { + auto _p_filename(request->getURLParam<::std::string>(_pi_filename)); + auto _responseModel = prx0->feelingLucky(_p_filename, request->getContext()); + if (_responseModel) { + request->responseRedirect(*_responseModel, "Mirror found"); + } + request->response(404, "No mirror found"); + } + + private: + const MirrorSearch::SearchPrx prx0; + const unsigned int _pi_filename; + }; + +} // namespace MirrorSearch + +// Register route handlers. +FACTORY(MirrorSearch::download, IceSpider::RouteHandlerFactory); + +// End generated code. + -- cgit v1.2.3