Skip to content

Commit

Permalink
Added HTTP POST handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Sevenisko committed Mar 23, 2024
1 parent 3badf24 commit 0b54d5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions code/framework/src/http/webserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ namespace Framework::HTTP {
}
}

void Webserver::RegisterPostRequest(const char* path, const PostCallback& callback) const {
if (strlen(path) > 0 && callback) {
_server->Post(path, callback);
}
}

void Webserver::ServeDirectory(const std::string &dir) {
_serveDir = dir;
if (!dir.empty())
Expand Down
2 changes: 2 additions & 0 deletions code/framework/src/http/webserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

namespace Framework::HTTP {
using RequestCallback = fu2::function<void(const httplib::Request &, httplib::Response &) const>;
using PostCallback = fu2::function<void(const httplib::Request &, httplib::Response &, const httplib::ContentReader &) const>;

class Webserver {
public:
Expand All @@ -29,6 +30,7 @@ namespace Framework::HTTP {
bool Shutdown();

void RegisterRequest(const char *, const RequestCallback &) const;
void RegisterPostRequest(const char *, const PostCallback &) const;

const std::string &GetServeDirectory() {
return _serveDir;
Expand Down

0 comments on commit 0b54d5e

Please sign in to comment.