diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-03-06 19:43:22 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-03-06 19:43:22 +0000 |
commit | 3131fa0db3000fb5c944e3822361de6fe7bb1b82 (patch) | |
tree | da0cfea27a5d0099eae95a1a1821b71b54afa644 /site/custom.cpp | |
parent | Initial commit, WIP (diff) | |
download | mirrorsearch-3131fa0db3000fb5c944e3822361de6fe7bb1b82.tar.bz2 mirrorsearch-3131fa0db3000fb5c944e3822361de6fe7bb1b82.tar.xz mirrorsearch-3131fa0db3000fb5c944e3822361de6fe7bb1b82.zip |
Add basic site setup
Diffstat (limited to 'site/custom.cpp')
-rw-r--r-- | site/custom.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
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<MirrorSearch::Search>()), + _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. + |