Skip to content

Commit 8d8fc0a

Browse files
committed
Caching changes needed
1 parent d044f27 commit 8d8fc0a

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/CachingApp.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class CachingHttpResponse {
3232
buffer.append(data);
3333
}
3434

35-
void end(std::string_view data = "") {
35+
void end(std::string_view data = "", bool closeConnection = false) {
3636
buffer.append(data);
3737

3838
// end for all queued up sockets also
@@ -71,8 +71,8 @@ struct CachingApp : public uWS::TemplatedApp<SSL, CachingApp<SSL>> {
7171
}
7272

7373
// variant 1: only taking URL into account
74-
CachingApp& get(const std::string& url, std::function<void(CachingHttpResponse*, uWS::HttpRequest*)> handler, unsigned int secondsToExpiry) {
75-
((uWS::TemplatedApp<SSL, CachingApp<SSL>> *)this)->get(url, [this, handler, secondsToExpiry](auto* res, auto* req) {
74+
CachingApp &&get(const std::string& url, uWS::MoveOnlyFunction<void(CachingHttpResponse*, uWS::HttpRequest*)> &&handler, unsigned int secondsToExpiry) {
75+
((uWS::TemplatedApp<SSL, CachingApp<SSL>> *)this)->get(url, [this, handler = std::move(handler), secondsToExpiry](auto* res, auto* req) mutable {
7676
/* We need to know the cache key and the time of now */
7777
std::string_view cache_key = req->getFullUrl();
7878
time_t now = static_cast<LoopData *>(us_loop_ext((us_loop_t *)uWS::Loop::get()))->cacheTimepoint;
@@ -97,9 +97,9 @@ struct CachingApp : public uWS::TemplatedApp<SSL, CachingApp<SSL>> {
9797
CachingHttpResponse *cachingRes;
9898
cache[cache_key] = (cachingRes = new CachingHttpResponse(res));
9999

100-
handler(cachingRes, req);
100+
handler(cachingRes, req);
101101
});
102-
return *this;
102+
return std::move(*this);
103103
}
104104

105105
// variant 2: taking URL and a list of headers into account

0 commit comments

Comments
 (0)