I'm taking inspiration from a few places, namely the simplicity of web.py, but the general structure and syntax of Rails appeals to me. I'd love to be able to do something like this in a controller file:
App.controller("Posts") do
function index()
end
end
As you can guess the App module would store the logic for the entire app, with the controller part looking something like this:
module App
function controller(actions, name::String)
println("Adding controller $name, $actions")
_controllers[name] = actions
end
end
Now, I'm definitely using this as a learning experience as I only have experience
using MVC rather than creating one. But, my simple understand would be at some point I hit a route that maps to that controller and action, and I'm going to want to call it.
Given that my action is a function inside of a function (using the syntax I'm attempting here), what would be a clean way to store this?
My hope was to store all the functions inside of controllers in a Dict ("controller#action" => function) which would make it extremely simple to call them. But I'm guessing there is no way for me to access and store the functions inside of the controller function.
My guess at this point is that I'll have to pass in the actions differently, unless there is some way to run a function inside a function arbitrarily ( totally incorrect I'm sure, but something like exec("function.function()")? )
Basically, looking for any advice on which way to take this! :)