Permalink
Browse files

Added cors.js example

  • Loading branch information...
1 parent bc7a9fa commit a8b1a1a15e86616f1c50d9ab480b8d1e5a27fc42 Duncan Smith committed Dec 8, 2013
Showing with 27 additions and 0 deletions.
  1. +27 −0 examples/cors.js
View
@@ -0,0 +1,27 @@
+var bogart = require('../lib/bogart');
+
+var router = bogart.router();
+router.get('/', function(req) {
+ return 'Hello Root';
+});
+
+router.get('/:name', function(req) {
+ return bogart.cors({message:'Hello, ' + req.params.name + '!'});
+});
+
+var app = bogart.app();
+app.use(bogart.batteries);
+app.use(router);
+
+app.start();
+
+/* From another domain:
+*
+* $.ajax({
+* url: 'http://localhost:8080/Duncan',
+* success: function(data) {
+* console.log(data);
+* }
+* });
+*
+*/

0 comments on commit a8b1a1a

Please sign in to comment.