mirror of
https://gitee.com/an-tao/drogon.git
synced 2024-12-02 03:38:03 +08:00
add TestController in example
This commit is contained in:
parent
584d90beaf
commit
d1f8b43833
12
examples/static_link_example/TestController.cc
Executable file
12
examples/static_link_example/TestController.cc
Executable file
@ -0,0 +1,12 @@
|
||||
#include "TestController.h"
|
||||
void TestController::asyncHandleHttpRequest(const HttpRequest& req,std::function<void (HttpResponse &)>callback)
|
||||
{
|
||||
std::unique_ptr<HttpResponse> resp=std::unique_ptr<HttpResponse>(HttpResponse::newHttpResponse());
|
||||
LOG_DEBUG<<"!!!!!!!!!!1";
|
||||
resp->setStatusCode(HttpResponse::k200Ok);
|
||||
|
||||
resp->setContentTypeCode(CT_TEXT_HTML);
|
||||
|
||||
resp->setBody("hello!!!");
|
||||
callback(*resp);
|
||||
}
|
18
examples/static_link_example/TestController.h
Executable file
18
examples/static_link_example/TestController.h
Executable file
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <drogon/HttpSimpleController.h>
|
||||
using namespace drogon;
|
||||
|
||||
class TestController:public drogon::HttpSimpleController<TestController>
|
||||
{
|
||||
public:
|
||||
//TestController(){}
|
||||
virtual void asyncHandleHttpRequest(const HttpRequest& req,std::function<void (HttpResponse &)>callback)override;
|
||||
|
||||
void ttt(){}
|
||||
PATH_LIST_BEGIN
|
||||
PATH_ADD("/");
|
||||
PATH_ADD("/Test","nonFilter");
|
||||
PATH_ADD("/tpost","drogon::PostFilter");
|
||||
PATH_LIST_END
|
||||
};
|
@ -19,28 +19,6 @@ public:
|
||||
// HHH(){std::cout<<"class HHH constr,name="<<className()<<std::endl;}
|
||||
};
|
||||
|
||||
class TestController:public drogon::HttpSimpleController<TestController>
|
||||
{
|
||||
public:
|
||||
TestController(){}
|
||||
virtual void asyncHandleHttpRequest(const HttpRequest& req,std::function<void (HttpResponse &)>callback)override
|
||||
{
|
||||
std::unique_ptr<HttpResponse> resp=std::unique_ptr<HttpResponse>(HttpResponse::newHttpResponse());
|
||||
LOG_DEBUG<<"!!!!!!!!!!1";
|
||||
resp->setStatusCode(HttpResponse::k200Ok);
|
||||
|
||||
resp->setContentTypeCode(CT_TEXT_HTML);
|
||||
|
||||
resp->setBody("hello!!!");
|
||||
callback(*resp);
|
||||
}
|
||||
void ttt(){}
|
||||
PATH_LIST_BEGIN
|
||||
PATH_ADD("/");
|
||||
PATH_ADD("/Test","nonFilter");
|
||||
PATH_ADD("/tpost","drogon::PostFilter");
|
||||
PATH_LIST_END
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -48,9 +26,6 @@ public:
|
||||
|
||||
int main()
|
||||
{
|
||||
//drogon::DrObjectBase *p=drogon::DrClassMap::newObject("HHH");
|
||||
//TestController haha;
|
||||
//std::cout<<haha.good()<<std::endl;
|
||||
|
||||
std::cout<<banner<<std::endl;
|
||||
drogon::HttpAppFramework::instance().setListening("0.0.0.0",12345);
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <drogon/DrObject.h>
|
||||
#include <drogon/HttpAppFramework.h>
|
||||
#include <trantor/utils/Logger.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
Loading…
Reference in New Issue
Block a user