var
  Surrogate = require(".."),
  surrogate = new Surrogate({
    port: 1337,
    ip: "0.0.0.0",
    verbose: false,
    initialState: {
      birthday: null
    }
  });

surrogate.jsonRoute({
  name: "set-info",
  method: "POST",
  path: "/api/person",
  handlers: {
    "set-person-success": {
      description: "Save the person's info.",
      handler: function (request) {
        this.state.birthday = request.payload.birthday;
        this.cookies.hasBirthday = true;
        return { status: "OK" };
      }
    }
  }
});

surrogate.htmlRoute({
  name: "get-info",
  method: "GET",
  path: "/api/person",
  handlers: {
    "get-person-success": {
      description: "Return info about the person.",
      handler: function (request, selectedOption) {
        var
          name = request.query.name || "Tommy Joe",
          birthday = this.state.birthday ?
            "has a birthday on " + this.state.birthday + "." :
            "has no birthday.";

        return selectedOption(name + " " + birthday);
      },
      optionsHelperText: "What should birthday info be wrapped in?",
      optionsType: "selectOne",
      options: {
        "wrap in body": function (str) {
          return "<html><body>" + str + "</body></html>";
        },
        "wrap in html": function (str) {
          return "<html>" + str + "</html>";
        }
      }
    },
    "get-person-error": {
      description: "Return an error instead of the person's info.",
      handler: function () {
        throw new Surrogate.HttpErr({
          code: 401,
          payload: "<html>can't do that right now...</html>"
        });
      }
    }
  }
});

surrogate.start();

@@ -1628,32 +1628,754 @@
 %0A    %7D%0A  %7D%0A%7D);%0A%0A
+surrogate.htmlRoute(%7B%0A  name: %22get-things%22,%0A  method: %22GET%22,%0A  path: %22/api/things%22,%0A  handlers: %7B%0A    %22get-things-success%22: %7B%0A      description: %22Return things.%22,%0A      handler: function (request, selectedOptions) %7B%0A        return selectedOptions.join(%22 %22);%0A      %7D,%0A      optionsHelperText: %22What thigns should be returned?%22,%0A      optionsType: %22selectMany%22,%0A      options: %7B%0A        %22thing 1%22: %22thing 1%22,%0A        %22thing 2%22: %22thing 2%22%0A      %7D%0A    %7D,%0A    %22get-things-error%22: %7B%0A      description: %22Return an error instead of the things.%22,%0A      handler: function () %7B%0A        throw new Surrogate.HttpErr(%7B%0A          code: 401,%0A          payload: %22%3Chtml%3Ecan't do that right now...%3C/html%3E%22%0A        %7D);%0A      %7D%0A    %7D%0A  %7D%0A%7D);%0A%0A
 surrogate.start(

add example for selectMany