コード例 #1
0
ファイル: main.js プロジェクト: botic/vicstick
app.get("/:alias/:property", function(req, alias, property) {
   var drummers = {
      "stevegadd": {
         birthday: 1945,
         fullname: "Steve Gadd",
         drumset: "Yamaha"
      },
      "ringostarr": {
         birthday: 1940,
         fullname: "Richard Henry Parkin Starkey Jr.",
         drumset: "Premier"
      },
      "jeff": {
         birthday: 1954,
         fullname: "Jeff Porcaro"
      }
   };
   
   // Check if a drummer exists
   if (drummers[alias]) {
      if (drummers[alias][property]) {
         return response.html(
            "<html><h1>Found a drummer's property:</h1>",
            "<p>", alias, ".", property, " is: <b>", drummers[alias][property], "</b></p>",
            "</html>"
         );
      } else {
         // Return a 404
         return response.notFound(alias + "/" + property);
      }
   } else {
      // Return a 404
      return response.notFound(alias);
   }
});
コード例 #2
0
ファイル: main.js プロジェクト: JStuhr/geoscript-js
exports.app = function(request) {
    var path = request.pathInfo.slice(1) || "index";
    // 1. resolve against actions
    if (typeof actions[path] === "function") {
        return actions[path](request);
    }
    // 2. resolve against static folder
    var resource = getResource("./static/" + path);
    if (resource.exists()) {
        return response.static(resource);
    }
    // 3. return 404 response
    return response.notFound(request.pathInfo);
}
コード例 #3
0
ファイル: httpclient_test.js プロジェクト: nubiofs/ringojs
 getResponse = function(req) {
     if (req.pathInfo == '/notfound') {
         return response.notFound().text("not found");
     } else if (req.pathInfo == '/success') {
         return response.json('success');
     } else if (req.pathInfo == '/redirect') {
         return {
             status: 302,
             headers: {Location: '/redirectlocation'},
             body: ["Found: " + '/redirectlocation']
         };
     } else if (req.pathInfo == '/redirectlocation') {
         return response.html('redirect success');
     }
 };
コード例 #4
0
ファイル: httpclient_test.js プロジェクト: nubiofs/ringojs
 getResponse = function(req) {
     return response.notFound();
 };
コード例 #5
0
ファイル: registry_test.js プロジェクト: grob/rp
 app.get("/api/users/:username/salt", function(request, username) {
     if (username === "johndoe") {
         return response.json("salt");
     }
     return response.notFound();
 });