mirror of
https://gitee.com/zyjblog/oatpp.git
synced 2024-12-22 22:16:37 +08:00
Implemented comments from PR
This commit is contained in:
parent
68e41f05c1
commit
23545685ce
@ -25,7 +25,7 @@
|
||||
|
||||
#define OATPP_MACRO_API_CONTROLLER_ADDCORS_BODY_DEFAULT_ORIGIN "*"
|
||||
#define OATPP_MACRO_API_CONTROLLER_ADDCORS_BODY_DEFAULT_METHODS "GET, POST, OPTIONS"
|
||||
#define OATPP_MACRO_API_CONTROLLER_ADDCORS_BODY_DEFAULT_HEADERS "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization"
|
||||
#define OATPP_MACRO_API_CONTROLLER_ADDCORS_BODY_DEFAULT_HEADERS "DNT, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Range, Authorization"
|
||||
#define OATPP_MACRO_API_CONTROLLER_ADDCORS_BODY_DEFAULT_MAX_AGE "1728000"
|
||||
|
||||
#define OATPP_MACRO_API_CONTROLLER_ADDCORS_BODY(ARG_ORIGIN, ARG_METHODS, ARG_HEADERS, ARG_MAX_AGE) \
|
||||
@ -35,7 +35,7 @@
|
||||
resp->putHeaderIfNotExists(oatpp::web::protocol::http::Header::CORS_MAX_AGE, ARG_MAX_AGE);
|
||||
|
||||
#define OATPP_MACRO_API_CONTROLLER_ADDCORS_MACRO_1(ENDPOINTNAME, ...) \
|
||||
ENDPOINT_INTERCEPTOR(ENDPOINTNAME, ZZ__CORS_INTERCEPTOR_##ENDPOINTNAME) { \
|
||||
ENDPOINT_INTERCEPTOR(ENDPOINTNAME, CORS) { \
|
||||
auto resp = (this->*intercepted)(request); \
|
||||
OATPP_MACRO_API_CONTROLLER_ADDCORS_BODY( \
|
||||
OATPP_MACRO_API_CONTROLLER_ADDCORS_BODY_DEFAULT_ORIGIN, \
|
||||
@ -57,7 +57,7 @@ ENDPOINT("OPTIONS", Z__ENDPOINT_##ENDPOINTNAME->info()->path, ZZ__CORS_OPTIONS_E
|
||||
}
|
||||
|
||||
#define OATPP_MACRO_API_CONTROLLER_ADDCORS_MACRO_2(ENDPOINTNAME, ORIGIN) \
|
||||
ENDPOINT_INTERCEPTOR(ENDPOINTNAME, ZZ__CORS_INTERCEPTOR_##ENDPOINTNAME) { \
|
||||
ENDPOINT_INTERCEPTOR(ENDPOINTNAME, CORS) { \
|
||||
auto resp = (this->*intercepted)(request); \
|
||||
OATPP_MACRO_API_CONTROLLER_ADDCORS_BODY( \
|
||||
ORIGIN, \
|
||||
@ -79,7 +79,7 @@ ENDPOINT("OPTIONS", Z__ENDPOINT_##ENDPOINTNAME->info()->path, ZZ__CORS_OPTIONS_E
|
||||
}
|
||||
|
||||
#define OATPP_MACRO_API_CONTROLLER_ADDCORS_MACRO_3(ENDPOINTNAME, ORIGIN, METHODS) \
|
||||
ENDPOINT_INTERCEPTOR(ENDPOINTNAME, ZZ__CORS_INTERCEPTOR_##ENDPOINTNAME) { \
|
||||
ENDPOINT_INTERCEPTOR(ENDPOINTNAME, CORS) { \
|
||||
auto resp = (this->*intercepted)(request); \
|
||||
OATPP_MACRO_API_CONTROLLER_ADDCORS_BODY( \
|
||||
ORIGIN, \
|
||||
@ -101,7 +101,7 @@ ENDPOINT("OPTIONS", Z__ENDPOINT_##ENDPOINTNAME->info()->path, ZZ__CORS_OPTIONS_E
|
||||
}
|
||||
|
||||
#define OATPP_MACRO_API_CONTROLLER_ADDCORS_MACRO_4(ENDPOINTNAME, ORIGIN, METHODS, HEADERS) \
|
||||
ENDPOINT_INTERCEPTOR(ENDPOINTNAME, ZZ__CORS_INTERCEPTOR_##ENDPOINTNAME) { \
|
||||
ENDPOINT_INTERCEPTOR(ENDPOINTNAME, CORS) { \
|
||||
auto resp = (this->*intercepted)(request); \
|
||||
OATPP_MACRO_API_CONTROLLER_ADDCORS_BODY( \
|
||||
ORIGIN, \
|
||||
@ -123,7 +123,7 @@ ENDPOINT("OPTIONS", Z__ENDPOINT_##ENDPOINTNAME->info()->path, ZZ__CORS_OPTIONS_E
|
||||
}
|
||||
|
||||
#define OATPP_MACRO_API_CONTROLLER_ADDCORS_MACRO_5(ENDPOINTNAME, ORIGIN, METHODS, HEADERS, MAX_AGE) \
|
||||
ENDPOINT_INTERCEPTOR(ENDPOINTNAME, ZZ__CORS_INTERCEPTOR_##ENDPOINTNAME) { \
|
||||
ENDPOINT_INTERCEPTOR(ENDPOINTNAME, CORS) { \
|
||||
auto resp = (this->*intercepted)(request); \
|
||||
OATPP_MACRO_API_CONTROLLER_ADDCORS_BODY(ORIGIN, METHODS, HEADERS, MAX_AGE) \
|
||||
return resp; \
|
||||
|
@ -53,60 +53,60 @@ void runTests() {
|
||||
|
||||
oatpp::base::Environment::printCompilationConfig();
|
||||
|
||||
// OATPP_LOGD("aaa", "coroutine size=%d", sizeof(oatpp::async::AbstractCoroutine));
|
||||
// OATPP_LOGD("aaa", "action size=%d", sizeof(oatpp::async::Action));
|
||||
//
|
||||
// OATPP_RUN_TEST(oatpp::test::base::RegRuleTest);
|
||||
// OATPP_RUN_TEST(oatpp::test::base::CommandLineArgumentsTest);
|
||||
//
|
||||
// OATPP_RUN_TEST(oatpp::test::memory::MemoryPoolTest);
|
||||
// OATPP_RUN_TEST(oatpp::test::memory::PerfTest);
|
||||
//
|
||||
// OATPP_RUN_TEST(oatpp::test::collection::LinkedListTest);
|
||||
//
|
||||
// OATPP_RUN_TEST(oatpp::test::core::data::share::MemoryLabelTest);
|
||||
// OATPP_RUN_TEST(oatpp::test::core::data::stream::ChunkedBufferTest);
|
||||
// OATPP_RUN_TEST(oatpp::test::core::data::mapping::type::TypeTest);
|
||||
//
|
||||
// OATPP_RUN_TEST(oatpp::test::async::LockTest);
|
||||
//
|
||||
// OATPP_RUN_TEST(oatpp::test::parser::CaretTest);
|
||||
// OATPP_RUN_TEST(oatpp::test::parser::json::mapping::DeserializerTest);
|
||||
// OATPP_RUN_TEST(oatpp::test::parser::json::mapping::DTOMapperPerfTest);
|
||||
// OATPP_RUN_TEST(oatpp::test::parser::json::mapping::DTOMapperTest);
|
||||
//
|
||||
// OATPP_RUN_TEST(oatpp::test::encoding::Base64Test);
|
||||
// OATPP_RUN_TEST(oatpp::test::encoding::UnicodeTest);
|
||||
//
|
||||
// OATPP_RUN_TEST(oatpp::test::network::UrlTest);
|
||||
// OATPP_RUN_TEST(oatpp::test::network::virtual_::PipeTest);
|
||||
// OATPP_RUN_TEST(oatpp::test::network::virtual_::InterfaceTest);
|
||||
//
|
||||
// OATPP_RUN_TEST(oatpp::test::web::mime::multipart::StatefulParserTest);
|
||||
//
|
||||
// OATPP_RUN_TEST(oatpp::test::web::server::api::ApiControllerTest);
|
||||
//
|
||||
// OATPP_RUN_TEST(oatpp::test::web::server::handler::AuthorizationHandlerTest);
|
||||
//
|
||||
// {
|
||||
//
|
||||
// oatpp::test::web::PipelineTest test_virtual(0, 3000);
|
||||
// test_virtual.run();
|
||||
//
|
||||
// oatpp::test::web::PipelineTest test_port(8000, 3000);
|
||||
// test_port.run();
|
||||
//
|
||||
// }
|
||||
//
|
||||
// {
|
||||
//
|
||||
// oatpp::test::web::PipelineAsyncTest test_virtual(0, 3000);
|
||||
// test_virtual.run();
|
||||
//
|
||||
// oatpp::test::web::PipelineAsyncTest test_port(8000, 3000);
|
||||
// test_port.run();
|
||||
//
|
||||
// }
|
||||
OATPP_LOGD("aaa", "coroutine size=%d", sizeof(oatpp::async::AbstractCoroutine));
|
||||
OATPP_LOGD("aaa", "action size=%d", sizeof(oatpp::async::Action));
|
||||
|
||||
OATPP_RUN_TEST(oatpp::test::base::RegRuleTest);
|
||||
OATPP_RUN_TEST(oatpp::test::base::CommandLineArgumentsTest);
|
||||
|
||||
OATPP_RUN_TEST(oatpp::test::memory::MemoryPoolTest);
|
||||
OATPP_RUN_TEST(oatpp::test::memory::PerfTest);
|
||||
|
||||
OATPP_RUN_TEST(oatpp::test::collection::LinkedListTest);
|
||||
|
||||
OATPP_RUN_TEST(oatpp::test::core::data::share::MemoryLabelTest);
|
||||
OATPP_RUN_TEST(oatpp::test::core::data::stream::ChunkedBufferTest);
|
||||
OATPP_RUN_TEST(oatpp::test::core::data::mapping::type::TypeTest);
|
||||
|
||||
OATPP_RUN_TEST(oatpp::test::async::LockTest);
|
||||
|
||||
OATPP_RUN_TEST(oatpp::test::parser::CaretTest);
|
||||
OATPP_RUN_TEST(oatpp::test::parser::json::mapping::DeserializerTest);
|
||||
OATPP_RUN_TEST(oatpp::test::parser::json::mapping::DTOMapperPerfTest);
|
||||
OATPP_RUN_TEST(oatpp::test::parser::json::mapping::DTOMapperTest);
|
||||
|
||||
OATPP_RUN_TEST(oatpp::test::encoding::Base64Test);
|
||||
OATPP_RUN_TEST(oatpp::test::encoding::UnicodeTest);
|
||||
|
||||
OATPP_RUN_TEST(oatpp::test::network::UrlTest);
|
||||
OATPP_RUN_TEST(oatpp::test::network::virtual_::PipeTest);
|
||||
OATPP_RUN_TEST(oatpp::test::network::virtual_::InterfaceTest);
|
||||
|
||||
OATPP_RUN_TEST(oatpp::test::web::mime::multipart::StatefulParserTest);
|
||||
|
||||
OATPP_RUN_TEST(oatpp::test::web::server::api::ApiControllerTest);
|
||||
|
||||
OATPP_RUN_TEST(oatpp::test::web::server::handler::AuthorizationHandlerTest);
|
||||
|
||||
{
|
||||
|
||||
oatpp::test::web::PipelineTest test_virtual(0, 3000);
|
||||
test_virtual.run();
|
||||
|
||||
oatpp::test::web::PipelineTest test_port(8000, 3000);
|
||||
test_port.run();
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
oatpp::test::web::PipelineAsyncTest test_virtual(0, 3000);
|
||||
test_virtual.run();
|
||||
|
||||
oatpp::test::web::PipelineAsyncTest test_port(8000, 3000);
|
||||
test_port.run();
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
|
@ -183,7 +183,7 @@ void FullTest::onRun() {
|
||||
OATPP_ASSERT(header->second.toString() == "GET, POST, OPTIONS");
|
||||
header = response->getHeaders().find(oatpp::web::protocol::http::Header::CORS_HEADERS);
|
||||
OATPP_ASSERT(header != response->getHeaders().end());
|
||||
OATPP_ASSERT(header->second.toString() == "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization");
|
||||
OATPP_ASSERT(header->second.toString() == "DNT, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Range, Authorization");
|
||||
}
|
||||
|
||||
{ // test simple OPTIONS with CORS
|
||||
@ -197,7 +197,7 @@ void FullTest::onRun() {
|
||||
OATPP_ASSERT(header->second.toString() == "GET, POST, OPTIONS");
|
||||
header = response->getHeaders().find(oatpp::web::protocol::http::Header::CORS_HEADERS);
|
||||
OATPP_ASSERT(header != response->getHeaders().end());
|
||||
OATPP_ASSERT(header->second.toString() == "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization");
|
||||
OATPP_ASSERT(header->second.toString() == "DNT, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Range, Authorization");
|
||||
}
|
||||
|
||||
{ // test simple GET with CORS
|
||||
@ -213,7 +213,7 @@ void FullTest::onRun() {
|
||||
OATPP_ASSERT(header->second.toString() == "GET, POST, OPTIONS");
|
||||
header = response->getHeaders().find(oatpp::web::protocol::http::Header::CORS_HEADERS);
|
||||
OATPP_ASSERT(header != response->getHeaders().end());
|
||||
OATPP_ASSERT(header->second.toString() == "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization");
|
||||
OATPP_ASSERT(header->second.toString() == "DNT, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Range, Authorization");
|
||||
}
|
||||
|
||||
{ // test simple GET with CORS
|
||||
@ -229,7 +229,7 @@ void FullTest::onRun() {
|
||||
OATPP_ASSERT(header->second.toString() == "GET, OPTIONS");
|
||||
header = response->getHeaders().find(oatpp::web::protocol::http::Header::CORS_HEADERS);
|
||||
OATPP_ASSERT(header != response->getHeaders().end());
|
||||
OATPP_ASSERT(header->second.toString() == "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization");
|
||||
OATPP_ASSERT(header->second.toString() == "DNT, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Range, Authorization");
|
||||
}
|
||||
|
||||
{ // test simple GET with CORS
|
||||
|
Loading…
Reference in New Issue
Block a user