Setup server
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Fri, 30 Oct 2015 09:00:54 +0000 (02:00 -0700)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Fri, 30 Oct 2015 09:00:54 +0000 (02:00 -0700)
12 files changed:
CODE_TAG [new file with mode: 0644]
README.md
SConstruct [new file with mode: 0644]
setup.sh [new file with mode: 0644]
src/bbmc.cpp [new file with mode: 0644]
src/bbmc.scons [new file with mode: 0644]
src/bbmc/App.cpp [new file with mode: 0644]
src/bbmc/App.h [new file with mode: 0644]
src/bbmc/Server.cpp [new file with mode: 0644]
src/bbmc/Server.h [new file with mode: 0644]
src/bbmc/Transaction.cpp [new file with mode: 0644]
src/bbmc/Transaction.h [new file with mode: 0644]

diff --git a/CODE_TAG b/CODE_TAG
new file mode 100644 (file)
index 0000000..1bb4d7c
--- /dev/null
+++ b/CODE_TAG
@@ -0,0 +1,27 @@
+             This file is part of the Buildbotics Machine Controller.
+
+                    Copyright (c) 2015-2016, Buildbotics LLC
+                               All rights reserved.
+
+        The Buildbotics Machine Controller is free software: you can
+        redistribute it and/or modify it under the terms of the GNU
+        General Public License as published by the Free Software
+        Foundation, either version 2 of the License, or (at your option)
+        any later version.
+
+        The Buildbotics Webserver is distributed in the hope that it will
+        be useful, but WITHOUT ANY WARRANTY; without even the implied
+        warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+        PURPOSE.  See the GNU General Public License for more details.
+
+        You should have received a copy of the GNU General Public License
+        along with this software.  If not, see
+        <http://www.gnu.org/licenses/>.
+
+        In addition, BSD licensing may be granted on a case by case basis
+        by written permission from at least one of the copyright holders.
+        You may request written permission by emailing the authors.
+
+                For information regarding this software email:
+                               Joseph Coffland
+                        joseph@cauldrondevelopment.com
index 1dda0d494ad354ee5dd87b30b333baaffa907bcb..2b827a2bae470ffe9b4f181639dbd9f78bc67387 100644 (file)
--- a/README.md
+++ b/README.md
@@ -5,18 +5,22 @@ These instructions are for a Debian *testing* development system targeting the R
 ## Download & install the base RPi system
 
 ```
-wget https://downloads.raspberrypi.org/raspbian_latest -O raspbian-jessie.zip
-unzip raspbian-jessie.zip
+wget https://downloads.raspberrypi.org/raspbian/images/raspbian-2015-05-07/2015-05-05-raspbian-wheezy.zip
+unzip 2015-05-05-raspbian-wheezy.zip
 ```
 
-Now copy the base system to an SD card.  You need to make sure you have the correct device in the command below or you can destroy your Linux system by overwriting the disk.
+Now copy the base system to an SD card.  You need a card with at least 4GiB.  After installing the RPi system all data on the SD card will be lost.  So make sure you back up the SD card if there's anything important on it
+
+In the command below, make sure you have the correct device or you can **destroy your Linux system** by overwriting the disk.  One way to do this is to run ``sudo tail -f /var/log/syslog`` before inserting the SD card.  After inserting the card look for log messages containing ``/dev/sdx`` where ``x`` is a letter.  This should be the device name of the SD card.  Hit ``CTRL-C`` to stop following the system log.
 
 ```
-sudo dd bs=4M if=2015-09-24-raspbian-jessie.img of=/dev/sdd
+sudo dd bs=4M if=2015-05-05-raspbian-wheezy.img of=/dev/sde
 sudo sync
 ```
 
-Insert the SD card into your RPi and power it on.  Plug in the network connection and determine IP address of the RPi.
+The first command takes awhile and does not produce any output until it's done.
+
+Insert the SD card into your RPi and power it on.  Plug in the network connection, wired or wireless.
 
 ## Login to the RPi
 
@@ -28,7 +32,7 @@ Login:
 ssh pi@<ip>
 ```
 
-Substitute ``<ip>`` with the correct IP address.  The default password is ``raspberry``.  You should see a prompt like this: ``pi@raspberrypi ~ $``
+Substitute ``<ip>`` with the correct IP address.  The default password is ``raspberry``.  You should see a prompt like this: ``pi@raspberrypi ~ $``, but in color.
 
 ## Configure the RPi
 Update the package system, install the network auto discovery deamon, change the hostname and reboot.
@@ -40,7 +44,7 @@ sudo sed -i 's/raspberrypi/bbctrl/' /etc/hosts /etc/hostname
 sudo reboot
 ```
 
-In the future you can now log in to the system like this:
+In the future, you can now log in to the system like this:
 
 ```
 ssh pi@bbctrl.local
@@ -54,9 +58,9 @@ sudo apt-get update
 sudo apt-get install -y gcc-arm-linux-gnueabihf
 ```
 
-# Compile and run a test program
+## Compile and run a test program
 
-On the developmnet system, create a file ``hello.c`` with these contents:
+On the development system, create a file ``hello.c`` with these contents:
 
 ```
 #include <stdio.h>
diff --git a/SConstruct b/SConstruct
new file mode 100644 (file)
index 0000000..f0ddf65
--- /dev/null
@@ -0,0 +1,91 @@
+# Setup
+import os
+env = Environment(ENV = os.environ)
+try:
+    env.Tool('config', toolpath = [os.environ.get('CBANG_HOME')])
+except Exception, e:
+    raise Exception, 'CBANG_HOME not set?\n' + str(e)
+
+env.CBLoadTools('compiler cbang dist resources build_info packager')
+conf = env.CBConfigure()
+
+# Settings
+name = 'bbmc'
+
+# Version
+version = '0.0.1'
+major, minor, revision = version.split('.')
+
+# Config vars
+env.Replace(PACKAGE_VERSION = version)
+env.Replace(RESOURCES_NS = 'bbmc')
+env.Replace(BUILD_INFO_NS = 'bbmc::BuildInfo')
+
+if not env.GetOption('clean') and not 'package' in COMMAND_LINE_TARGETS:
+    conf.CBConfig('compiler')
+
+    conf.CBConfig('cbang')
+    env.CBDefine('USING_CBANG') # Using CBANG macro namespace
+
+    conf.CBRequireLib('re2')
+    conf.CBRequireCXXHeader('re2/re2.h')
+
+conf.Finish()
+
+# Program
+Export('env name')
+prog, lib = \
+    SConscript('src/%s.scons' % name, variant_dir = 'build', duplicate = 0)
+Default(prog)
+
+# Clean
+Clean(prog, ['build', 'config.log'])
+
+# Dist
+docs = ['README.md']
+tar = env.TarBZ2Dist(name, docs + [prog])
+Alias('dist', tar)
+AlwaysBuild(tar)
+
+description = \
+'''
+Buildbotics Machine Controller
+'''
+
+short_description = description
+
+
+if 'package' in COMMAND_LINE_TARGETS:
+    pkg = env.Packager(
+        name,
+        version = version,
+        maintainer = 'Joseph Coffland <joseph@cauldrondevelopment.com>',
+        vendor = 'Buildbotics LLC',
+        url = 'http://github.com/buildbotics/machine-controller/',
+        license = 'copyright',
+        bug_url = 'https://github.com/buildbotics/machine-controller/issues',
+        summary = 'Buildbotics Machine Controller',
+        description = description,
+        prefix = '/usr',
+
+        documents = docs,
+        programs = [str(prog[0])],
+        init_d = [['scripts/' + name + '.init.d', name]],
+        changelog = 'ChangeLog',
+
+        deb_directory = 'debian',
+        deb_section = 'science',
+        deb_depends = 'debconf | debconf-2.0, libc6, bzip2, zlib1g',
+        deb_pre_depends = 'adduser, ssl-cert',
+        deb_priority = 'optional',
+        )
+
+    AlwaysBuild(pkg)
+    env.Alias('package', pkg)
+
+    f = None
+    try:
+        f = open('package-description.txt', 'w')
+        f.write(short_description.strip())
+    finally:
+        if f is not None: f.close()
diff --git a/setup.sh b/setup.sh
new file mode 100644 (file)
index 0000000..bf649bb
--- /dev/null
+++ b/setup.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# Update the system
+apt-get update
+apt-get dist-upgrade -y
+
+# Install the auto discovery daemon
+apt-get install -y avahi-daemon
+
+# Change the hostname
+sed -i 's/raspberrypi/bbctrl/' /etc/hosts /etc/hostname
+
+# Create bb user
+useradd -m -p buildbotics -s /bin/bash user
+
+# Remove pi user
+cd /
+userdel -rf pi
+
+reboot
diff --git a/src/bbmc.cpp b/src/bbmc.cpp
new file mode 100644 (file)
index 0000000..2a05f86
--- /dev/null
@@ -0,0 +1,44 @@
+/******************************************************************************\
+
+             This file is part of the Buildbotics Machine Controller.
+
+                    Copyright (c) 2015-2016, Buildbotics LLC
+                               All rights reserved.
+
+        The Buildbotics Machine Controller is free software: you can
+        redistribute it and/or modify it under the terms of the GNU
+        General Public License as published by the Free Software
+        Foundation, either version 2 of the License, or (at your option)
+        any later version.
+
+        The Buildbotics Webserver is distributed in the hope that it will
+        be useful, but WITHOUT ANY WARRANTY; without even the implied
+        warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+        PURPOSE.  See the GNU General Public License for more details.
+
+        You should have received a copy of the GNU General Public License
+        along with this software.  If not, see
+        <http://www.gnu.org/licenses/>.
+
+        In addition, BSD licensing may be granted on a case by case basis
+        by written permission from at least one of the copyright holders.
+        You may request written permission by emailing the authors.
+
+                For information regarding this software email:
+                               Joseph Coffland
+                        joseph@cauldrondevelopment.com
+
+\******************************************************************************/
+
+#include <cbang/ApplicationMain.h>
+#include <cbang/event/Event.h>
+
+#include <bbmc/App.h>
+
+int main(int argc, char *argv[]) {
+#ifdef DEBUG
+  cb::Event::Event::enableDebugMode();
+#endif
+
+  return cb::doApplication<bbmc::App>(argc, argv);
+}
diff --git a/src/bbmc.scons b/src/bbmc.scons
new file mode 100644 (file)
index 0000000..283a46b
--- /dev/null
@@ -0,0 +1,34 @@
+import glob
+
+Import('*')
+
+env.Append(CPPPATH = ['#/src'])
+
+subdirs = ['']
+
+# Source
+src = []
+for dir in subdirs:
+    src += Glob('bbmc/' + dir + '/*.cpp')
+
+
+# Resources
+res = env.Resources('resources.cpp', ['#/src/resources'])
+resLib = env.Library(name + 'Resources', res)
+Precious(resLib)
+
+# Build lib
+lib = env.Library(name, src)
+
+
+# Build Info
+info = env.BuildInfo('build_info.cpp', [])
+AlwaysBuild(info)
+
+# Main program
+prog = env.Program('#/' + name, [name + '.cpp', info, lib, resLib]);
+
+
+# Return
+pair = (prog, lib)
+Return('pair')
diff --git a/src/bbmc/App.cpp b/src/bbmc/App.cpp
new file mode 100644 (file)
index 0000000..36c3646
--- /dev/null
@@ -0,0 +1,106 @@
+/******************************************************************************\
+
+             This file is part of the Buildbotics Machine Controller.
+
+                    Copyright (c) 2015-2016, Buildbotics LLC
+                               All rights reserved.
+
+        The Buildbotics Machine Controller is free software: you can
+        redistribute it and/or modify it under the terms of the GNU
+        General Public License as published by the Free Software
+        Foundation, either version 2 of the License, or (at your option)
+        any later version.
+
+        The Buildbotics Webserver is distributed in the hope that it will
+        be useful, but WITHOUT ANY WARRANTY; without even the implied
+        warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+        PURPOSE.  See the GNU General Public License for more details.
+
+        You should have received a copy of the GNU General Public License
+        along with this software.  If not, see
+        <http://www.gnu.org/licenses/>.
+
+        In addition, BSD licensing may be granted on a case by case basis
+        by written permission from at least one of the copyright holders.
+        You may request written permission by emailing the authors.
+
+                For information regarding this software email:
+                               Joseph Coffland
+                        joseph@cauldrondevelopment.com
+
+\******************************************************************************/
+
+#include "App.h"
+
+#include <cbang/util/DefaultCatch.h>
+#include <cbang/log/Logger.h>
+#include <cbang/event/Event.h>
+
+#include <stdlib.h>
+#include <unistd.h>
+
+using namespace bbmc;
+using namespace cb;
+using namespace std;
+
+
+App::App() :
+  ServerApplication("Buildbotics Machine Controller", &App::_hasFeature),
+  dns(base), client(base, dns), server(*this) {
+
+  options.pushCategory("Buildbotics Machine Controller");
+  options.add("http-root", "Serve /* files from this directory.");
+  options.popCategory();
+
+  options.pushCategory("Debugging");
+  options.add("debug-libevent", "Enable verbose libevent debugging"
+              )->setDefault(false);
+  options.popCategory();
+
+  // Enable libevent logging
+  Event::Event::enableLogging(3);
+}
+
+
+bool App::_hasFeature(int feature) {
+  if (feature == FEATURE_LIFELINE) return true;
+  return ServerApplication::_hasFeature(feature);
+}
+
+int App::init(int argc, char *argv[]) {
+  int i = ServerApplication::init(argc, argv);
+  if (i == -1) return -1;
+
+  // Libevent debugging
+  if (options["debug-libevent"].toBoolean()) Event::Event::enableDebugLogging();
+
+  server.init();
+
+  // Check lifeline
+  if (getLifeline()) base.newEvent(this, &App::lifelineEvent).add(0.25);
+
+  // Handle exit signal
+  base.newSignal(SIGINT, this, &App::signalEvent).add();
+  base.newSignal(SIGTERM, this, &App::signalEvent).add();
+
+  return 0;
+}
+
+
+void App::run() {
+  try {
+    base.dispatch();
+    LOG_INFO(1, "Clean exit");
+  } CATCH_ERROR;
+}
+
+
+void App::lifelineEvent(Event::Event &e, int signal, unsigned flags) {
+  e.add(0.25);
+  if (shouldQuit()) base.loopExit();
+}
+
+
+void App::signalEvent(Event::Event &e, int signal, unsigned flags) {
+  base.loopExit();
+}
diff --git a/src/bbmc/App.h b/src/bbmc/App.h
new file mode 100644 (file)
index 0000000..67ca809
--- /dev/null
@@ -0,0 +1,79 @@
+/******************************************************************************\
+
+             This file is part of the Buildbotics Machine Controller.
+
+                    Copyright (c) 2015-2016, Buildbotics LLC
+                               All rights reserved.
+
+        The Buildbotics Machine Controller is free software: you can
+        redistribute it and/or modify it under the terms of the GNU
+        General Public License as published by the Free Software
+        Foundation, either version 2 of the License, or (at your option)
+        any later version.
+
+        The Buildbotics Webserver is distributed in the hope that it will
+        be useful, but WITHOUT ANY WARRANTY; without even the implied
+        warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+        PURPOSE.  See the GNU General Public License for more details.
+
+        You should have received a copy of the GNU General Public License
+        along with this software.  If not, see
+        <http://www.gnu.org/licenses/>.
+
+        In addition, BSD licensing may be granted on a case by case basis
+        by written permission from at least one of the copyright holders.
+        You may request written permission by emailing the authors.
+
+                For information regarding this software email:
+                               Joseph Coffland
+                        joseph@cauldrondevelopment.com
+
+\******************************************************************************/
+
+#ifndef BBMC_APP_H
+#define BBMC_APP_H
+
+#include "Server.h"
+
+#include <cbang/ServerApplication.h>
+#include <cbang/net/IPAddress.h>
+
+#include <cbang/event/Base.h>
+#include <cbang/event/DNSBase.h>
+#include <cbang/event/Client.h>
+
+namespace cb {
+  namespace Event {class Event;}
+}
+
+
+namespace bbmc {
+  class App : public cb::ServerApplication {
+    cb::Event::Base base;
+    cb::Event::DNSBase dns;
+    cb::Event::Client client;
+
+    Server server;
+
+  public:
+    App();
+
+    static bool _hasFeature(int feature);
+
+    cb::Event::Base &getEventBase() {return base;}
+    cb::Event::DNSBase &getEventDNS() {return dns;}
+    cb::Event::Client &getEventClient() {return client;}
+
+    Server &getServer() {return server;}
+
+    // From cb::Application
+    int init(int argc, char *argv[]);
+    void run();
+
+    void lifelineEvent(cb::Event::Event &e, int signal, unsigned flags);
+    void signalEvent(cb::Event::Event &e, int signal, unsigned flags);
+  };
+}
+
+#endif // BBMC_APP_H
+
diff --git a/src/bbmc/Server.cpp b/src/bbmc/Server.cpp
new file mode 100644 (file)
index 0000000..03765e7
--- /dev/null
@@ -0,0 +1,102 @@
+/******************************************************************************\
+
+             This file is part of the Buildbotics Machine Controller.
+
+                    Copyright (c) 2015-2016, Buildbotics LLC
+                               All rights reserved.
+
+        The Buildbotics Machine Controller is free software: you can
+        redistribute it and/or modify it under the terms of the GNU
+        General Public License as published by the Free Software
+        Foundation, either version 2 of the License, or (at your option)
+        any later version.
+
+        The Buildbotics Webserver is distributed in the hope that it will
+        be useful, but WITHOUT ANY WARRANTY; without even the implied
+        warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+        PURPOSE.  See the GNU General Public License for more details.
+
+        You should have received a copy of the GNU General Public License
+        along with this software.  If not, see
+        <http://www.gnu.org/licenses/>.
+
+        In addition, BSD licensing may be granted on a case by case basis
+        by written permission from at least one of the copyright holders.
+        You may request written permission by emailing the authors.
+
+                For information regarding this software email:
+                               Joseph Coffland
+                        joseph@cauldrondevelopment.com
+
+\******************************************************************************/
+
+#include "Server.h"
+#include "App.h"
+#include "Transaction.h"
+
+#include <cbang/openssl/SSLContext.h>
+
+#include <cbang/event/Request.h>
+#include <cbang/event/PendingRequest.h>
+#include <cbang/event/Buffer.h>
+#include <cbang/event/RedirectSecure.h>
+#include <cbang/event/ResourceHTTPHandler.h>
+#include <cbang/event/FileHandler.h>
+
+#include <cbang/config/Options.h>
+#include <cbang/util/Resource.h>
+#include <cbang/log/Logger.h>
+
+#include <stdlib.h>
+
+using namespace cb;
+using namespace std;
+using namespace bbmc;
+
+namespace bbmc {
+  extern const DirectoryResource resource0;
+}
+
+
+Server::Server(App &app) :
+  Event::WebServer(app.getOptions(), app.getEventBase()), app(app) {
+}
+
+
+void Server::init() {
+  Event::WebServer::init();
+
+  // Event::HTTP request callbacks
+  HTTPHandlerGroup &api = *addGroup(HTTP_ANY, "/api/.*");
+
+#define ADD_TM(GROUP, METHODS, PATTERN, FUNC)                           \
+  (GROUP).addMember<Transaction>(METHODS, PATTERN, &Transaction::FUNC)
+
+  // API not found
+  ADD_TM(api, HTTP_ANY, "", apiNotFound);
+
+  // Docs
+  HTTPHandlerGroup &docs = *addGroup(HTTP_ANY, "/docs/.*");
+  if (app.getOptions()["http-root"].hasValue())
+    docs.addHandler(app.getOptions()["http-root"]);
+  else docs.addHandler(*resource0.find("http"));
+
+  docs.addMember<Transaction>(HTTP_ANY, ".*\\..*", &Transaction::notFound);
+
+  // Root
+  if (app.getOptions()["http-root"].hasValue()) {
+    string root = app.getOptions()["http-root"];
+
+    addHandler(root);
+    addHandler(root + "/index.html");
+
+  } else {
+    addHandler(*resource0.find("http"));
+    addHandler(*resource0.find("http/index.html"));
+  }
+}
+
+
+Event::Request *Server::createRequest(evhttp_request *req) {
+  return new Transaction(app, req);
+}
diff --git a/src/bbmc/Server.h b/src/bbmc/Server.h
new file mode 100644 (file)
index 0000000..4c8dce5
--- /dev/null
@@ -0,0 +1,56 @@
+/******************************************************************************\
+
+             This file is part of the Buildbotics Machine Controller.
+
+                    Copyright (c) 2015-2016, Buildbotics LLC
+                               All rights reserved.
+
+        The Buildbotics Machine Controller is free software: you can
+        redistribute it and/or modify it under the terms of the GNU
+        General Public License as published by the Free Software
+        Foundation, either version 2 of the License, or (at your option)
+        any later version.
+
+        The Buildbotics Webserver is distributed in the hope that it will
+        be useful, but WITHOUT ANY WARRANTY; without even the implied
+        warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+        PURPOSE.  See the GNU General Public License for more details.
+
+        You should have received a copy of the GNU General Public License
+        along with this software.  If not, see
+        <http://www.gnu.org/licenses/>.
+
+        In addition, BSD licensing may be granted on a case by case basis
+        by written permission from at least one of the copyright holders.
+        You may request written permission by emailing the authors.
+
+                For information regarding this software email:
+                               Joseph Coffland
+                        joseph@cauldrondevelopment.com
+
+\******************************************************************************/
+
+#ifndef BBMC_SERVER_H
+#define BBMC_SERVER_H
+
+#include <cbang/event/WebServer.h>
+
+
+namespace bbmc {
+  class App;
+
+  class Server : public cb::Event::WebServer {
+    App &app;
+
+  public:
+    Server(App &app);
+
+    void init();
+
+    // From cb::Event::HTTPHandler
+    cb::Event::Request *createRequest(evhttp_request *req);
+  };
+}
+
+#endif // BBMC_SERVER_H
+
diff --git a/src/bbmc/Transaction.cpp b/src/bbmc/Transaction.cpp
new file mode 100644 (file)
index 0000000..e33d8b8
--- /dev/null
@@ -0,0 +1,65 @@
+/******************************************************************************\
+
+             This file is part of the Buildbotics Machine Controller.
+
+                    Copyright (c) 2015-2016, Buildbotics LLC
+                               All rights reserved.
+
+        The Buildbotics Machine Controller is free software: you can
+        redistribute it and/or modify it under the terms of the GNU
+        General Public License as published by the Free Software
+        Foundation, either version 2 of the License, or (at your option)
+        any later version.
+
+        The Buildbotics Webserver is distributed in the hope that it will
+        be useful, but WITHOUT ANY WARRANTY; without even the implied
+        warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+        PURPOSE.  See the GNU General Public License for more details.
+
+        You should have received a copy of the GNU General Public License
+        along with this software.  If not, see
+        <http://www.gnu.org/licenses/>.
+
+        In addition, BSD licensing may be granted on a case by case basis
+        by written permission from at least one of the copyright holders.
+        You may request written permission by emailing the authors.
+
+                For information regarding this software email:
+                               Joseph Coffland
+                        joseph@cauldrondevelopment.com
+
+\******************************************************************************/
+
+#include "Transaction.h"
+#include "App.h"
+
+#include <cbang/json/JSON.h>
+#include <cbang/log/Logger.h>
+#include <cbang/util/DefaultCatch.h>
+
+using namespace std;
+using namespace cb;
+using namespace bbmc;
+
+
+Transaction::Transaction(App &app, evhttp_request *req) :
+  Request(req), app(app) {
+  LOG_DEBUG(5, "Transaction()");
+}
+
+
+Transaction::~Transaction() {
+  LOG_DEBUG(5, "~Transaction()");
+}
+
+
+bool Transaction::apiNotFound() {
+  THROWXS("Invalid API method " << getURI().getPath(), HTTP_NOT_FOUND);
+  return true;
+}
+
+
+bool Transaction::notFound() {
+  THROWXS("Not found " << getURI().getPath(), HTTP_NOT_FOUND);
+  return true;
+}
diff --git a/src/bbmc/Transaction.h b/src/bbmc/Transaction.h
new file mode 100644 (file)
index 0000000..8f6190d
--- /dev/null
@@ -0,0 +1,65 @@
+/******************************************************************************\
+
+             This file is part of the Buildbotics Machine Controller.
+
+                    Copyright (c) 2015-2016, Buildbotics LLC
+                               All rights reserved.
+
+        The Buildbotics Machine Controller is free software: you can
+        redistribute it and/or modify it under the terms of the GNU
+        General Public License as published by the Free Software
+        Foundation, either version 2 of the License, or (at your option)
+        any later version.
+
+        The Buildbotics Webserver is distributed in the hope that it will
+        be useful, but WITHOUT ANY WARRANTY; without even the implied
+        warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+        PURPOSE.  See the GNU General Public License for more details.
+
+        You should have received a copy of the GNU General Public License
+        along with this software.  If not, see
+        <http://www.gnu.org/licenses/>.
+
+        In addition, BSD licensing may be granted on a case by case basis
+        by written permission from at least one of the copyright holders.
+        You may request written permission by emailing the authors.
+
+                For information regarding this software email:
+                               Joseph Coffland
+                        joseph@cauldrondevelopment.com
+
+\******************************************************************************/
+
+#ifndef BBMC_TRANSACTION_H
+#define BBMC_TRANSACTION_H
+
+#include <cbang/event/Request.h>
+#include <cbang/event/RequestMethod.h>
+#include <cbang/event/PendingRequest.h>
+
+
+namespace cb {
+  namespace JSON {
+    class Writer;
+    class Value;
+  }
+}
+
+
+namespace bbmc {
+  class App;
+
+  class Transaction : public cb::Event::Request {
+    App &app;
+
+  public:
+    Transaction(App &app, evhttp_request *req);
+    ~Transaction();
+
+    bool apiNotFound();
+    bool notFound();
+  };
+}
+
+#endif // BBMC_TRANSACTION_H
+