Move freeswitch logic into its own controller

This commit is contained in:
Sam Dodrill 2015-01-07 13:25:38 -08:00
parent 7c71009a46
commit c992d1b080
2 changed files with 17 additions and 10 deletions

View File

@ -9,17 +9,8 @@ require "models.user"
class App extends lapis.Application class App extends lapis.Application
@include "controllers.users" @include "controllers.users"
@include "controllers.freeswitch"
[index: "/"]: => [index: "/"]: =>
@user = @session.user @user = @session.user
render: true render: true
[freeswitch: "/freeswitch"]: respond_to {
POST: =>
uid = @params["user"] or @params["sip_auth_username"]
@user = Users\find extension: uid
if not @user
return status: 404, "no such user"
render: true, layout: false
}

View File

@ -0,0 +1,16 @@
lapis = require "lapis"
import respond_to from require "lapis.application"
require "models.user"
class Freeswitch extends lapis.Application
[freeswitch: "/freeswitch"]: respond_to {
POST: =>
uid = @params["user"] or @params["sip_auth_username"]
@user = Users\find extension: uid
if not @user
return status: 404, "no such user"
render: true, layout: false
}