diff options
| author | Stefan Boberg <[email protected]> | 2021-08-20 22:17:13 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-08-20 22:17:13 +0200 |
| commit | 1901f186e28a5ce2cf63c32334d7d923fe0f44f1 (patch) | |
| tree | e5cc374398242bb02bc12e86682c88538a7cc5ea /zenserver/compute/apply.cpp | |
| parent | Restructured http server code in preparation for cross platform implementation (diff) | |
| download | zen-1901f186e28a5ce2cf63c32334d7d923fe0f44f1.tar.xz zen-1901f186e28a5ce2cf63c32334d7d923fe0f44f1.zip | |
WIP services
Diffstat (limited to 'zenserver/compute/apply.cpp')
| -rw-r--r-- | zenserver/compute/apply.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/zenserver/compute/apply.cpp b/zenserver/compute/apply.cpp index 59617bc9a..02a714cf0 100644 --- a/zenserver/compute/apply.cpp +++ b/zenserver/compute/apply.cpp @@ -316,12 +316,33 @@ SandboxedFunctionJob::SpawnJob(std::filesystem::path ExePath) return true; } -HttpFunctionService::HttpFunctionService(CasStore& Store, const std::filesystem::path& SandboxBaseDir) -: m_Log("exec", begin(spdlog::default_logger()->sinks()), end(spdlog::default_logger()->sinks())) +HttpFunctionService::HttpFunctionService(CasStore& Store, const std::filesystem::path& BaseDir) +: m_Log("apply", begin(spdlog::default_logger()->sinks()), end(spdlog::default_logger()->sinks())) , m_CasStore(Store) -, m_SandboxPath(SandboxBaseDir) +, m_SandboxPath(BaseDir / "scratch") +, m_FunctionPath(BaseDir / "func") { m_Router.AddPattern("job", "([[:digit:]]+)"); + m_Router.AddPattern("function", "([[:xdigit:]]{40})"); + + m_Router.RegisterRoute( + "functions/{function}", + [this](HttpRouterRequest& Req) { + HttpServerRequest& HttpReq = Req.ServerRequest(); + + switch (HttpReq.RequestVerb()) + { + case HttpVerb::kGet: + break; + + case HttpVerb::kPost: + { + CbObject FunctionSpec = HttpReq.ReadPayloadObject(); + } + break; + } + }, + HttpVerb::kGet | HttpVerb::kPost); m_Router.RegisterRoute( "jobs/{job}", @@ -507,7 +528,7 @@ HttpFunctionService::~HttpFunctionService() const char* HttpFunctionService::BaseUri() const { - return "/func/"; + return "/apply/"; } void |