Remove expired filter classes

This commit is contained in:
antao 2019-01-16 10:03:11 +08:00
parent 7661b8ed88
commit 01de7f4f1e
14 changed files with 8 additions and 247 deletions

View File

@ -208,7 +208,7 @@ void create_controller::newHttpControllerHeaderFile(std::ofstream &file, const s
file << indent << "//METHOD_ADD(" << class_name << "::get,\"/get/{2}/{1}\",Get);"
"//path will be "
<< namepace_path << class_name << "/get/{arg2}/{arg1}\n";
file << indent << "//METHOD_ADD(" << class_name << "::your_method_name,\"/{1}/{2}/list\",\"drogon::GetFilter\");"
file << indent << "//METHOD_ADD(" << class_name << "::your_method_name,\"/{1}/{2}/list\",Get);"
"//path will be "
<< namepace_path << class_name << "/{arg1}/{arg2}/list\n";
file << indent << "\n";

View File

@ -10,6 +10,6 @@ class JsonTestController : public drogon::HttpSimpleController<JsonTestControlle
virtual void asyncHandleHttpRequest(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback) override;
PATH_LIST_BEGIN
PATH_ADD("/json", "drogon::GetFilter", "drogon::LocalHostFilter");
PATH_ADD("/json", Get, "drogon::LocalHostFilter");
PATH_LIST_END
};

View File

@ -12,7 +12,7 @@ class TestController : public drogon::HttpSimpleController<TestController>
//PATH_ADD("/path","filter1","filter2",...);
PATH_ADD("/");
PATH_ADD("/Test", "nonFilter");
PATH_ADD("/tpost", "drogon::PostFilter");
PATH_ADD("/tpost", Post);
PATH_ADD("/slow", "TimeFilter", Get);
PATH_LIST_END
};

View File

@ -10,10 +10,10 @@ class ApiTest : public drogon::HttpController<ApiTest>
public:
METHOD_LIST_BEGIN
//use METHOD_ADD to add your custom processing function here;
METHOD_ADD(ApiTest::get, "/get/{2}/{1}", "drogon::GetFilter"); //path will be /api/v1/apitest/get/{arg2}/{arg1}
METHOD_ADD(ApiTest::get, "/get/{2}/{1}", Get); //path will be /api/v1/apitest/get/{arg2}/{arg1}
METHOD_ADD(ApiTest::your_method_name, "/{1}/List?P2={2}", Get); //path will be /api/v1/apitest/{arg1}/list
METHOD_ADD(ApiTest::staticApi, "/static", Get, Post);
METHOD_ADD(ApiTest::get2, "/get/{1}", "drogon::GetFilter");
METHOD_ADD(ApiTest::get2, "/get/{1}", Get);
METHOD_LIST_END
//your declaration of processing function maybe like this:
void get(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback, int p1, std::string &&p2);

View File

@ -63,8 +63,8 @@ class Test : public HttpController<Test>
{
public:
METHOD_LIST_BEGIN
METHOD_ADD(Test::get, "get/{2}/{1}", "drogon::GetFilter"); //path will be /api/v1/test/get/{arg2}/{arg1}
METHOD_ADD(Test::list, "/{2}/info", "drogon::GetFilter"); //path will be /api/v1/test/{arg2}/info
METHOD_ADD(Test::get, "get/{2}/{1}", Get); //path will be /api/v1/test/get/{arg2}/{arg1}
METHOD_ADD(Test::list, "/{2}/info", Get); //path will be /api/v1/test/{arg2}/info
METHOD_LIST_END
void get(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback, int p1, int p2) const
{

View File

@ -1,29 +0,0 @@
/**
*
* DeleteFilter.h
* An Tao
*
* Copyright 2018, An Tao. All rights reserved.
* https://github.com/an-tao/drogon
* Use of this source code is governed by a MIT license
* that can be found in the License file.
*
* Drogon
*
*/
#pragma once
#include <drogon/HttpFilter.h>
namespace drogon
{
class DeleteFilter : public HttpFilter<DeleteFilter>
{
public:
DeleteFilter() {}
virtual void doFilter(const HttpRequestPtr &req,
const FilterCallback &fcb,
const FilterChainCallback &fccb) override;
};
} // namespace drogon

View File

@ -1,29 +0,0 @@
/**
*
* GetFilter.h
* An Tao
*
* Copyright 2018, An Tao. All rights reserved.
* https://github.com/an-tao/drogon
* Use of this source code is governed by a MIT license
* that can be found in the License file.
*
* Drogon
*
*/
#pragma once
#include <drogon/HttpFilter.h>
namespace drogon
{
class GetFilter : public HttpFilter<GetFilter>
{
public:
GetFilter() {}
virtual void doFilter(const HttpRequestPtr &req,
const FilterCallback &fcb,
const FilterChainCallback &fccb) override;
};
} // namespace drogon

View File

@ -24,10 +24,7 @@
#include <drogon/DrObject.h>
#include <drogon/HttpRequest.h>
#include <drogon/HttpResponse.h>
#include <drogon/PostFilter.h>
#include <drogon/GetFilter.h>
#include <drogon/PutFilter.h>
#include <drogon/DeleteFilter.h>
#include <drogon/HttpFilter.h>
#include <drogon/LocalHostFilter.h>
#include <drogon/InnerIpFilter.h>
#include <drogon/version.h>

View File

@ -1,29 +0,0 @@
/**
*
* PostFilter.h
* An Tao
*
* Copyright 2018, An Tao. All rights reserved.
* https://github.com/an-tao/drogon
* Use of this source code is governed by a MIT license
* that can be found in the License file.
*
* Drogon
*
*/
#pragma once
#include <drogon/HttpFilter.h>
namespace drogon
{
class PostFilter : public HttpFilter<PostFilter>
{
public:
PostFilter() {}
virtual void doFilter(const HttpRequestPtr &req,
const FilterCallback &fcb,
const FilterChainCallback &fccb) override;
};
} // namespace drogon

View File

@ -1,29 +0,0 @@
/**
*
* PutFilter.h
* An Tao
*
* Copyright 2018, An Tao. All rights reserved.
* https://github.com/an-tao/drogon
* Use of this source code is governed by a MIT license
* that can be found in the License file.
*
* Drogon
*
*/
#pragma once
#include <drogon/HttpFilter.h>
namespace drogon
{
class PutFilter : public HttpFilter<PutFilter>
{
public:
PutFilter() {}
virtual void doFilter(const HttpRequestPtr &req,
const FilterCallback &fcb,
const FilterChainCallback &fccb) override;
};
} // namespace drogon

View File

@ -1,30 +0,0 @@
/**
*
* DeleteFilter.cc
* An Tao
*
* Copyright 2018, An Tao. All rights reserved.
* https://github.com/an-tao/drogon
* Use of this source code is governed by a MIT license
* that can be found in the License file.
*
* Drogon
*
*/
#include <drogon/DeleteFilter.h>
#include "HttpResponseImpl.h"
using namespace drogon;
void DeleteFilter::doFilter(const HttpRequestPtr &req,
const FilterCallback &fcb,
const FilterChainCallback &fccb)
{
if (req->method() == Delete)
{
fccb();
return;
}
auto res = drogon::HttpResponse::newHttpResponse();
res->setStatusCode(HttpResponse::k405MethodNotAllowed);
fcb(res);
}

View File

@ -1,30 +0,0 @@
/**
*
* GetFilter.cc
* An Tao
*
* Copyright 2018, An Tao. All rights reserved.
* https://github.com/an-tao/drogon
* Use of this source code is governed by a MIT license
* that can be found in the License file.
*
* Drogon
*
*/
#include <drogon/GetFilter.h>
#include "HttpResponseImpl.h"
using namespace drogon;
void GetFilter::doFilter(const HttpRequestPtr &req,
const FilterCallback &fcb,
const FilterChainCallback &fccb)
{
if (req->method() == Get)
{
fccb();
return;
}
auto res = drogon::HttpResponse::newHttpResponse();
res->setStatusCode(HttpResponse::k405MethodNotAllowed);
fcb(res);
}

View File

@ -1,30 +0,0 @@
/**
*
* PostFilter.cc
* An Tao
*
* Copyright 2018, An Tao. All rights reserved.
* https://github.com/an-tao/drogon
* Use of this source code is governed by a MIT license
* that can be found in the License file.
*
* Drogon
*
*/
#include <drogon/PostFilter.h>
#include "HttpResponseImpl.h"
using namespace drogon;
void PostFilter::doFilter(const HttpRequestPtr &req,
const FilterCallback &fcb,
const FilterChainCallback &fccb)
{
if (req->method() == Post)
{
fccb();
return;
}
auto res = drogon::HttpResponse::newHttpResponse();
res->setStatusCode(HttpResponse::k405MethodNotAllowed);
fcb(res);
}

View File

@ -1,30 +0,0 @@
/**
*
* PutFilter.cc
* An Tao
*
* Copyright 2018, An Tao. All rights reserved.
* https://github.com/an-tao/drogon
* Use of this source code is governed by a MIT license
* that can be found in the License file.
*
* Drogon
*
*/
#include <drogon/PutFilter.h>
#include "HttpResponseImpl.h"
using namespace drogon;
void PutFilter::doFilter(const HttpRequestPtr &req,
const FilterCallback &fcb,
const FilterChainCallback &fccb)
{
if (req->method() == Put)
{
fccb();
return;
}
auto res = drogon::HttpResponse::newHttpResponse();
res->setStatusCode(HttpResponse::k405MethodNotAllowed);
fcb(res);
}