diff --git a/app.moon b/app.moon index 8baa228..66cef5a 100644 --- a/app.moon +++ b/app.moon @@ -9,17 +9,8 @@ require "models.user" class App extends lapis.Application @include "controllers.users" + @include "controllers.freeswitch" [index: "/"]: => @user = @session.user 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 - } diff --git a/controllers/freeswitch.moon b/controllers/freeswitch.moon new file mode 100644 index 0000000..3a9bab6 --- /dev/null +++ b/controllers/freeswitch.moon @@ -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 + }