aboutsummaryrefslogtreecommitdiff
path: root/mod/mod-ci-github.cxx
diff options
context:
space:
mode:
authorFrancois Kritzinger <francois@codesynthesis.com>2024-01-29 14:14:55 +0200
committerFrancois Kritzinger <francois@codesynthesis.com>2024-06-05 09:12:45 +0200
commit9f162ff6e470c7dad7adf724047e34bc7720e164 (patch)
tree37164c1dc29beec1adbfae59c9d762d62ca11a97 /mod/mod-ci-github.cxx
parentcd4f3526a6192735bf5c8b7d9d3dd56077bb703d (diff)
Create mod-ci-github (from mod-ci)
Diffstat (limited to 'mod/mod-ci-github.cxx')
-rw-r--r--mod/mod-ci-github.cxx61
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");
+}