diff options
author | Francois Kritzinger <francois@codesynthesis.com> | 2024-01-29 14:14:55 +0200 |
---|---|---|
committer | Francois Kritzinger <francois@codesynthesis.com> | 2024-10-15 09:05:27 +0200 |
commit | 9fd45364160ee4cb5af22c34b36a10e9cba8ad89 (patch) | |
tree | be47d711969f852636d024299bafe00a86918e57 /mod/mod-ci-github.cxx | |
parent | 268c5ff3ac06c1ad834b98551cc038e00c84f229 (diff) |
Create mod-ci-github (from mod-ci)
Diffstat (limited to 'mod/mod-ci-github.cxx')
-rw-r--r-- | mod/mod-ci-github.cxx | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/mod/mod-ci-github.cxx b/mod/mod-ci-github.cxx new file mode 100644 index 0000000..b31c144 --- /dev/null +++ b/mod/mod-ci-github.cxx @@ -0,0 +1,61 @@ +// file : mod/mod-ci-github.cxx -*- C++ -*- +// license : MIT; see accompanying LICENSE file + +#include <mod/mod-ci-github.hxx> + +//#include <libbutl/manifest-parser.hxx> +#include <libbutl/manifest-serializer.hxx> + +#include <mod/module-options.hxx> + +using namespace std; +using namespace butl; +using namespace web; +using namespace brep::cli; + +brep::ci_github:: +ci_github (const ci_github& r) + : handler (r) +{ +} + +void brep::ci_github:: +init (scanner& s) +{ + options_ = make_shared<options::ci> ( + s, unknown_mode::fail, unknown_mode::fail); +} + +bool brep::ci_github:: +handle (request& /*rq*/, response& rs) +{ + using namespace bpkg; + using namespace xhtml; + + // using parser = manifest_parser; + // using parsing = manifest_parsing; + using serializer = manifest_serializer; + // using serialization = manifest_serialization; + + HANDLER_DIAG; + + string request_id; // Will be set later. + auto respond_manifest = [&rs, &request_id] (status_code status, + const string& message) -> bool + { + serializer s (rs.content (status, "text/manifest;charset=utf-8"), + "response"); + + s.next ("", "1"); // Start of manifest. + s.next ("status", to_string (status)); + s.next ("message", message); + + if (!request_id.empty ()) + s.next ("reference", request_id); + + s.next ("", ""); // End of manifest. + return true; + }; + + return respond_manifest (404, "XXX CI request submission disabled"); +} |