Skip to content

Commit

Permalink
Merge pull request #8 from arahlin/compat
Browse files Browse the repository at this point in the history
Compatibility fixes, using OSX 1.7.3 and Clang 14.0.0.
  • Loading branch information
gsmecher authored Feb 21, 2024
2 parents 00ff272 + 95e0ec1 commit e37ce8c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: etr/libhttpserver
ref: 0.18.2
ref: 0.19.0
path: libhttpserver

- name: Install Python dependencies
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ find_package(pybind11 REQUIRED)
include(CTest)

add_executable(tuberd src/server.cpp)
target_link_libraries(tuberd PRIVATE boost_program_options fmt::fmt httpserver pybind11::embed)
target_link_libraries(tuberd PRIVATE Boost::program_options fmt::fmt ${LIBHTTPSERVER_LIBRARIES} pybind11::embed)

pybind11_add_module(test_module MODULE tests/test_module.cpp)
target_include_directories(test_module PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
Expand Down
7 changes: 4 additions & 3 deletions src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class DLL_LOCAL tuber_resource : public http_resource {
json_loads(json_loads),
json_dumps(json_dumps) {};

const std::shared_ptr<http_response> render(const http_request& req) {
std::shared_ptr<http_response> render(const http_request& req) {
/* Acquire the GIL. This makes us thread-safe -
* but any methods we invoke should release the
* GIL (especially if they do their own
Expand All @@ -235,7 +235,8 @@ class DLL_LOCAL tuber_resource : public http_resource {
fmt::print(stderr, "Request: {}\n", req.get_content());

/* Parse JSON */
py::object request_obj = json_loads(req.get_content());
std::string content(req.get_content());
py::object request_obj = json_loads(content);

if(py::isinstance<py::dict>(request_obj)) {
/* Simple JSON object - invoke it and return the results. */
Expand Down Expand Up @@ -313,7 +314,7 @@ class DLL_LOCAL file_resource : public http_resource {
public:
file_resource(fs::path webroot, int max_age) : webroot(webroot), max_age(max_age) {};

const std::shared_ptr<http_response> render_GET(const http_request& req) {
std::shared_ptr<http_response> render_GET(const http_request& req) {
/* Start with webroot and append path segments from
* HTTP request.
*
Expand Down
3 changes: 2 additions & 1 deletion tests/test_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class Wrapper {
bool is_y(Kind const& k) const { return k == Kind::Y; }

std::vector<int> increment(std::vector<int> x) {
std::ranges::for_each(x, [](int &n) { n++; });
for (auto &i : x)
i++;
return x;
};
};
Expand Down

0 comments on commit e37ce8c

Please sign in to comment.