         else
           for k, v of arguments[0]
             route verb: verb, path: k, handler: v
-
   context.js = (obj) ->
     for k, v of obj
       js = String(v)

        res.contentType(r.contentType) if r.contentType?
        if typeof result is 'string' then res.send result
        else return result
  
  # Register socket.io handlers.
  io.sockets.on 'connection', (socket) ->
    c = {}
    
    build_ctx = ->
      ctx =
        app: app
        io: io
        settings: app.settings
        socket: socket
        id: socket.id
        emit: ->
          if typeof arguments[0] isnt 'object'
            socket.emit.apply socket, arguments
          else
            for k, v of arguments[0]
              socket.emit.apply socket, [k, v]
        broadcast: ->
          if typeof arguments[0] isnt 'object'
            socket.broadcast.emit.apply socket.broadcast, arguments
          else
            for k, v of arguments[0]
              socket.broadcast.emit.apply socket.broadcast, [k, v]

      for name, helper of helpers
        do (name, helper) ->
          ctx[name] = ->
            helper.apply(ctx, arguments)
      ctx

    ctx = build_ctx()
    ws_handlers.connection.apply(ctx, [ctx]) if ws_handlers.connection?

    socket.on 'disconnect', ->
      ctx = build_ctx()
      ws_handlers.disconnect.apply(ctx, [ctx]) if ws_handlers.disconnect?

    for name, h of ws_handlers
      do (name, h) ->
        if name isnt 'connection' and name isnt 'disconnect'
          socket.on name, (data) ->
            ctx = build_ctx()
            ctx.data = data
            switch app.settings['databag']
              when 'this' then h.apply(data, [ctx])

      helpers[k] = v

  context.on = (obj) ->
    for name, h of obj
      if ws_handlers[name]?
        for socket in @io.sockets.clients()
          socket.removeAllListeners name
          socket.on name, (data) ->
            ctx = build_ctx(socket)
            h.apply(ctx, [ctx])
      ws_handlers[name] = h
  context.view = (obj) ->
    for k, v of obj
      views["#{context.id}/#{k}"] = v
