Bugfix/testing framework typo (#32)
parent
3885b0c0ec
commit
bcf13e7cb1
|
@ -2,7 +2,7 @@
|
|||
|
||||
```c++
|
||||
void disableSession();
|
||||
void enableSession(const size_t timeout=0);
|
||||
void enableSession(const size_t timeout=0, Cookie::SameSite sameSite=Cooie::SameSite::kNull);
|
||||
```
|
||||
|
||||
都是通过`HttpAppFramework`单例调用,timeout参数代表了会话失效的时间,单位是秒,框架默认值是1200,即如果用户20分钟以上没有访问应用,则他对应的会话就失效了。timeout设置为0表示drogon将在整个生存期保留用户的会话;
|
||||
|
@ -95,4 +95,4 @@ drogon::HttpAppFramework::instance().enableSession(1200);
|
|||
|
||||
用cmake重新编译整个工程,运行目标程序webapp,就可以通过浏览器看到效果了。
|
||||
|
||||
# [数据库](CHN-08-0-数据库-概述)
|
||||
# [数据库](CHN-08-0-数据库-概述)
|
||||
|
|
|
@ -101,9 +101,9 @@ Drogon 是一个异步网站框架。 它仅遵循因此 DrogonTest 支持测试
|
|||
DROGON_TEST(RemoteAPITest)
|
||||
{
|
||||
auto client = HttpClient::newHttpClient("http://localhost:8848");
|
||||
auto req = HttpReuqest::newHttpRequest();
|
||||
auto req = HttpRequest::newHttpRequest();
|
||||
req->setPath("/");
|
||||
client->sendRequest(req, [TEST_CTX](ReqResuelt res, const HttpResponsePtr& resp) {
|
||||
client->sendRequest(req, [TEST_CTX](ReqResult res, const HttpResponsePtr& resp) {
|
||||
// There's nothing we can do if the request didn't reach the server
|
||||
// or the server generated garbage.
|
||||
REQUIRE(res == ReqResult::Ok);
|
||||
|
@ -122,7 +122,7 @@ DROGON_TEST(RemoteAPITestCoro)
|
|||
{
|
||||
auto api_test = [TEST_CTX]() {
|
||||
auto client = HttpClient::newHttpClient("http://localhost:8848");
|
||||
auto req = HttpReuqest::newHttpRequest();
|
||||
auto req = HttpRequest::newHttpRequest();
|
||||
req->setPath("/");
|
||||
|
||||
auto resp = co_await client->sendRequestCoro(req);
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
```c++
|
||||
void disableSession();
|
||||
void enableSession(const size_t timeout=0);
|
||||
void enableSession(const size_t timeout=0, Cookie::SameSite sameSite=Cooie::SameSite::kNull);
|
||||
```
|
||||
|
||||
The above methods are all called through the `HttpAppFramework` singleton. The timeout parameter represents the time when the session is invalid. The unit is second. The default value is 1200. That is, if the user does not access the web application for more than 20 minutes, the corresponding session will be invalid. Setting timeout to 0 means that drogon will retain the user's session for the entire lifetime;
|
||||
|
||||
The sameSite parameter changes the SameSite attribute of the Set-Cookie HTTP response header.
|
||||
|
||||
Make sure your client supports cookies before opening the session feature. Otherwise, drogon will create a new session for each request without `SessionID` cookie, which will waste memory and computing resources.
|
||||
|
||||
|
@ -95,4 +95,4 @@ drogon::HttpAppFramework::instance().enableSession(1200);
|
|||
|
||||
Recompile the entire project with cmake, run the target program webapp, and you can see the effect through the browser.
|
||||
|
||||
# 08.0 [Database](ENG-08-0-Database-General)
|
||||
# 08.0 [Database](ENG-08-0-Database-General)
|
||||
|
|
|
@ -101,9 +101,9 @@ Drogon is a asynchronous web framework. It only follows DrogonTest supports test
|
|||
DROGON_TEST(RemoteAPITest)
|
||||
{
|
||||
auto client = HttpClient::newHttpClient("http://localhost:8848");
|
||||
auto req = HttpReuqest::newHttpRequest();
|
||||
auto req = HttpRequest::newHttpRequest();
|
||||
req->setPath("/");
|
||||
client->sendRequest(req, [TEST_CTX](ReqResuelt res, const HttpResponsePtr& resp) {
|
||||
client->sendRequest(req, [TEST_CTX](ReqResult res, const HttpResponsePtr& resp) {
|
||||
// There's nothing we can do if the request didn't reach the server
|
||||
// or the server generated garbage.
|
||||
REQUIRE(res == ReqResult::Ok);
|
||||
|
@ -122,7 +122,7 @@ DROGON_TEST(RemoteAPITestCoro)
|
|||
{
|
||||
auto api_test = [TEST_CTX]() {
|
||||
auto client = HttpClient::newHttpClient("http://localhost:8848");
|
||||
auto req = HttpReuqest::newHttpRequest();
|
||||
auto req = HttpRequest::newHttpRequest();
|
||||
req->setPath("/");
|
||||
|
||||
auto resp = co_await client->sendRequestCoro(req);
|
||||
|
|
Loading…
Reference in New Issue