Commits

Blake Winton  committed 1e61898

Add a first cut at an API List, so that I can tell what I should be hitting.

  • Participants
  • Parent commits 0a49296

Comments (0)

Files changed (1)

File packages/thunderbird-rest-api/lib/tb-rest-api.js

-function ApiHandler() {
+function FacebookPostApiHandler() {
   this.handle = function(request, response) {
     var body = JSON.parse(request.readBody());
     var tbUtils = require("tb-utils");
   };
 }
 
+function ApiListHandler() {
+  this.handle = function(request, response) {
+    var responseBody = "<html><title>APIs</title><body>" +
+        "<a href='post-facebook-message'>post-facebook-message</a>" +
+      "</body></html>";
+    response.setStatusLine(request.httpVersion, 200, "OK");
+    response.setHeader("Content-Type", "text/html", false);
+    response.setHeader("Content-Length", responseBody.length.toString(),
+                       false);
+    response.setHeader("Access-Control-Allow-Origin", "*", false);
+    response.write(responseBody);
+  };
+}
+
 var Server = exports.Server = function Server(port) {
   var httpd = require("httpd");
   var server = new httpd.nsHttpServer();
 
   server.start(port);
-  server.registerPathHandler("/post-facebook-message", new ApiHandler());
+  server.registerPathHandler("/post-facebook-message", new FacebookPostApiHandler());
+  server.registerPathHandler("/api", new ApiListHandler());
   return server;
 };