From c992d1b080839f71a0791467c5363739ad159f83 Mon Sep 17 00:00:00 2001 From: Sam Dodrill Date: Wed, 7 Jan 2015 13:25:38 -0800 Subject: [PATCH] Move freeswitch logic into its own controller --- app.moon | 11 +---------- controllers/freeswitch.moon | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 controllers/freeswitch.moon 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 + }