Rename the InnerIpFilter class

This commit is contained in:
antao 2019-03-14 11:25:12 +08:00
parent 8d6a1ed643
commit 053c760d27
6 changed files with 41 additions and 12 deletions

View File

@ -10,7 +10,7 @@ class ApiTest : public drogon::HttpController<ApiTest>
public:
METHOD_LIST_BEGIN
//use METHOD_ADD to add your custom processing function here;
METHOD_ADD(ApiTest::rootGet, "", "TimeFilter", Get, "drogon::LocalHostFilter", "drogon::InnerIpFilter");
METHOD_ADD(ApiTest::rootGet, "", "TimeFilter", Get, "drogon::LocalHostFilter", "drogon::IntranetIpFilter");
METHOD_ADD(ApiTest::rootPost, "", Post);
METHOD_ADD(ApiTest::get, "/get/{2}/{1}", Get); //path is /api/v1/apitest/get/{arg2}/{arg1}
METHOD_ADD(ApiTest::your_method_name, "/{1}/List?P2={2}", Get); //path is /api/v1/apitest/{arg1}/list

View File

@ -26,7 +26,7 @@
#include <drogon/HttpResponse.h>
#include <drogon/HttpFilter.h>
#include <drogon/LocalHostFilter.h>
#include <drogon/InnerIpFilter.h>
#include <drogon/IntranetIpFilter.h>
#include <drogon/version.h>
#include <drogon/NotFound.h>
#include <drogon/HttpClient.h>

View File

@ -1,6 +1,6 @@
/**
*
* InnerIpFilter.h
* IntranetIpFilter.h
* An Tao
*
* Copyright 2018, An Tao. All rights reserved.
@ -18,10 +18,10 @@
namespace drogon
{
class InnerIpFilter : public HttpFilter<InnerIpFilter>
class IntranetIpFilter : public HttpFilter<IntranetIpFilter>
{
public:
InnerIpFilter() {}
IntranetIpFilter() {}
virtual void doFilter(const HttpRequestPtr &req,
const FilterCallback &fcb,
const FilterChainCallback &fccb) override;

View File

@ -1,6 +1,6 @@
/**
*
* InnerIpFilter.cc
* IntranetIpFilter.cc
* An Tao
*
* Copyright 2018, An Tao. All rights reserved.
@ -12,14 +12,14 @@
*
*/
#include <drogon/InnerIpFilter.h>
#include <drogon/IntranetIpFilter.h>
#include "HttpResponseImpl.h"
using namespace drogon;
void InnerIpFilter::doFilter(const HttpRequestPtr &req,
const FilterCallback &fcb,
const FilterChainCallback &fccb)
void IntranetIpFilter::doFilter(const HttpRequestPtr &req,
const FilterCallback &fcb,
const FilterChainCallback &fccb)
{
if (req->peerAddr().isInnerIp())
if (req->peerAddr().isIntranetIp())
{
fccb();
return;

View File

@ -0,0 +1,29 @@
/**
*
* IntranetIpFilter.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/IntranetIpFilter.h>
#include "HttpResponseImpl.h"
using namespace drogon;
void IntranetIpFilter::doFilter(const HttpRequestPtr &req,
const FilterCallback &fcb,
const FilterChainCallback &fccb)
{
if (req->peerAddr().isIntranetIp())
{
fccb();
return;
}
auto res = drogon::HttpResponse::newNotFoundResponse();
fcb(res);
}

@ -1 +1 @@
Subproject commit 29e0b57f6970085886a8c0e702b11237ac5e70d3
Subproject commit cbda3283552b8fd53de86c7fc645a727d0934644