Skip to content

Commit 0c473a4

Browse files
scallopedllamaJoe Balough
authored andcommitted
Response: Add static fileResponse method
Add a static fileResponse method that creates and returns a file response, modeled after the text, json, and html response methods.
1 parent dcf0b38 commit 0c473a4

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/main/c/Response.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
// POSSIBILITY OF SUCH DAMAGE.
2525

2626
#include "internal/ConcreteResponse.h"
27+
#include "seasocks/util/FileResponse.h"
2728

2829
#include "seasocks/Response.h"
2930

@@ -69,4 +70,8 @@ std::shared_ptr<Response> Response::htmlResponse(const std::string& response) {
6970
SynchronousResponse::Headers(), true);
7071
}
7172

73+
std::shared_ptr<Response> Response::fileResponse(const Request &request, const std::string &filePath, const std::string &contentType, bool allowCompression, bool allowCaching) {
74+
return std::make_shared<FileResponse>(request, filePath, contentType, allowCompression, allowCaching);
75+
}
76+
7277
}

src/main/c/seasocks/Response.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#pragma once
2727

28+
#include "seasocks/Request.h"
2829
#include "seasocks/ResponseCode.h"
2930

3031
#include <map>
@@ -52,6 +53,7 @@ class Response {
5253
static std::shared_ptr<Response> textResponse(const std::string& response);
5354
static std::shared_ptr<Response> jsonResponse(const std::string& response);
5455
static std::shared_ptr<Response> htmlResponse(const std::string& response);
56+
static std::shared_ptr<Response> fileResponse(const Request &request, const std::string &filePath, const std::string &contentType, bool allowCompression, bool allowCaching);
5557
};
5658

5759
}

0 commit comments

Comments
 (0)