Skip to content

Commit 44bc3db

Browse files
committed
Re-make getter methods immutable
1 parent 9549b3f commit 44bc3db

31 files changed

+233
-499
lines changed

examples/allowing_disallowing_methods.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ using namespace httpserver;
2424

2525
class hello_world_resource : public http_resource {
2626
public:
27-
const std::shared_ptr<http_response> render(http_request&) {
27+
const std::shared_ptr<http_response> render(const http_request&) {
2828
return std::shared_ptr<http_response>(new string_response("Hello, World!"));
2929
}
3030
};

examples/basic_authentication.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ using namespace httpserver;
2525
class user_pass_resource : public httpserver::http_resource
2626
{
2727
public:
28-
const std::shared_ptr<http_response> render_GET(http_request& req)
28+
const std::shared_ptr<http_response> render_GET(const http_request& req)
2929
{
3030
if (req.get_user() != "myuser" || req.get_pass() != "mypass")
3131
{

examples/benchmark_select.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class hello_world_resource : public http_resource {
1414
{
1515
}
1616

17-
const std::shared_ptr<http_response> render(http_request&) {
17+
const std::shared_ptr<http_response> render(const http_request&) {
1818
return resp;
1919
}
2020

examples/benchmark_threads.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class hello_world_resource : public http_resource {
1414
{
1515
}
1616

17-
const std::shared_ptr<http_response> render(http_request&) {
17+
const std::shared_ptr<http_response> render(const http_request&) {
1818
return resp;
1919
}
2020

examples/custom_access_log.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void custom_access_log(const std::string& url) {
2929

3030
class hello_world_resource : public http_resource {
3131
public:
32-
const std::shared_ptr<http_response> render(http_request&) {
32+
const std::shared_ptr<http_response> render(const http_request&) {
3333
return std::shared_ptr<http_response>(new string_response("Hello, World!"));
3434
}
3535
};

examples/custom_error.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@
2222

2323
using namespace httpserver;
2424

25-
const std::shared_ptr<http_response> not_found_custom( http_request& req)
25+
const std::shared_ptr<http_response> not_found_custom(const http_request& req)
2626
{
2727
return std::shared_ptr<string_response>(new string_response("Not found custom", 404, "text/plain"));
2828
}
2929

30-
const std::shared_ptr<http_response> not_allowed_custom(http_request& req)
30+
const std::shared_ptr<http_response> not_allowed_custom(const http_request& req)
3131
{
3232
return std::shared_ptr<string_response>(new string_response("Not allowed custom", 405, "text/plain"));
3333
}
3434

3535
class hello_world_resource : public http_resource {
3636
public:
37-
const std::shared_ptr<http_response> render(http_request&) {
37+
const std::shared_ptr<http_response> render(const http_request&) {
3838
return std::shared_ptr<http_response>(new string_response("Hello, World!"));
3939
}
4040
};

examples/digest_authentication.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ using namespace httpserver;
2626

2727
class digest_resource : public httpserver::http_resource {
2828
public:
29-
const std::shared_ptr<http_response> render_GET(http_request& req) {
29+
const std::shared_ptr<http_response> render_GET(const http_request& req) {
3030
if (req.get_digested_user() == "") {
3131
return std::shared_ptr<digest_auth_fail_response>(new digest_auth_fail_response("FAIL", "test@example.com", MY_OPAQUE, true));
3232
}

examples/handlers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ using namespace httpserver;
2424

2525
class hello_world_resource : public http_resource {
2626
public:
27-
const std::shared_ptr<http_response> render_GET(http_request&) {
27+
const std::shared_ptr<http_response> render_GET(const http_request&) {
2828
return std::shared_ptr<http_response>(new string_response("GET: Hello, World!"));
2929
}
3030

31-
const std::shared_ptr<http_response> render(http_request&) {
31+
const std::shared_ptr<http_response> render(const http_request&) {
3232
return std::shared_ptr<http_response>(new string_response("OTHER: Hello, World!"));
3333
}
3434
};

examples/hello_with_get_arg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ using namespace httpserver;
2424

2525
class hello_world_resource : public http_resource {
2626
public:
27-
const std::shared_ptr<http_response> render(http_request& req) {
27+
const std::shared_ptr<http_response> render(const http_request& req) {
2828
return std::shared_ptr<http_response>(new string_response("Hello: " + req.get_arg("name")));
2929
}
3030
};

examples/hello_world.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ using namespace httpserver;
2525

2626
class hello_world_resource : public http_resource {
2727
public:
28-
const std::shared_ptr<http_response> render(http_request&);
28+
const std::shared_ptr<http_response> render(const http_request&);
2929
void set_some_data(const std::string &s) {data = s;}
3030
std::string data;
3131
};
3232

3333
//using the render method you are able to catch each type of request you receive
34-
const std::shared_ptr<http_response> hello_world_resource::render(http_request& req)
34+
const std::shared_ptr<http_response> hello_world_resource::render(const http_request& req)
3535
{
3636
//it is possible to store data inside the resource object that can be altered
3737
//through the requests

0 commit comments

Comments
 (0)