From 7d04735aca12cbf2e8bc8fda0930279350042392 Mon Sep 17 00:00:00 2001 From: Francois Kritzinger Date: Mon, 29 Jan 2024 14:14:55 +0200 Subject: Create mod-ci-github (from mod-ci) --- mod/mod-ci-github.cxx | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 mod/mod-ci-github.cxx (limited to 'mod/mod-ci-github.cxx') 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 + +//#include +#include + +#include + +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 ( + 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"); +} -- cgit v1.1