Permalink
Browse files

request

  • Loading branch information...
vovazolotoy committed Aug 28, 2011
1 parent 5774531 commit 925ffe594b35d3214314f995c3932c9ef03ff7ac
Showing with 46 additions and 705 deletions.
  1. +7 −0 application/bootstrap.js
  2. +0 −2 johana.js
  3. +38 −0 system/prototypes/johana/arr.js
  4. +1 −703 system/prototypes/request.js
View
@@ -10,3 +10,10 @@ Johana.init({
Johana.conf.attach(new ConfigFile());
+require('http').createServer(function (req, res) {
+ console.log(req.url);
+ res.writeHead(200, {'Content-Type': 'text/plain'});
+ res.end('Hello World\n');
+}).listen(1337, "127.0.0.1");
+
+console.log('Server running at http://127.0.0.1:1337/');
View
@@ -41,5 +41,3 @@ require(SYSPATH + 'prototypes/autoload');
// Bootstrap the application
require(APPPATH + 'bootstrap');
-
-console.log(Johana.config('vova.name'));
@@ -159,4 +159,42 @@ JohanaArr.merge = function(destination, source)
return destination;
};
+/**
+ * Retrieve a single key from an object. If the key does not exist in the
+ * object, the default value will be returned instead.
+ *
+ * // Get the value "username" from POST, if it exists
+ * var username = Arr.get(POST, 'username');
+ *
+ * // Get the value "sorting" from GET, if it exists
+ * var sorting = Arr.get(GET, 'sorting');
+ *
+ * @param Object object to extract from
+ * @param String key name
+ * @param Mixed default value
+ * @return Mixed
+ */
+JohanaArr.get = function(obj, key, def)
+{
+ def = def || null;
+
+ return (obj[key] === undefined) ? def : obj[key];
+};
+
+/**
+ * Check if object is empty
+ *
+ * @param Object object to check
+ * @return Boolean
+ */
+JohanaArr.isEmpty = function(source)
+{
+ for (var prop in source)
+ {
+ if (source.hasOwnProperty(prop)) return false;
+ }
+
+ return true;
+};
+
module.exports = JohanaArr; // End
Oops, something went wrong.

0 comments on commit 925ffe5

Please sign in to comment.