On May 5, 2015, at 6:30 PM, Herwig Hochleitner <[email protected]> wrote:
> Cool Idea! Convention based routing is a great way to get started quickly and
> I think that it actually might make a lot of people, asking for clojure
> frameworks, happy.
> I'm not aware of any clojure lib that does that, but I'd like to speculate a
> bit on what it might mean:
>
> As it happens, when I hear 'convention based routing', I think of mapping web
> paths to file system paths, the way most web servers do, where resource
> variants and/or behavior are configured by path patterns (most often by
> suffix a'la *.php).
>
> A lot could be said about the merit of letting people use just their file
> browser to set up even moderately complex web apps, but of course there are
> also downsides:
> This approach leads to components being scattered over multiple files, where
> n files would need to be renamed to rename a single resource.
> Also it probably won't interact well with java's classpath loading, so a
> leiningen plugin would be needed to index the app before packaging.
Yup, arbitrary URL-to-file system mapping is often horrible.
Here’s how FW/1 works:
* A request comes in for /foo/bar
* FW/1 attempts to require {appname}.controllers.foo
* If that succeeds, FW/1 attempts to resolve {appname}.controllers.foo/bar as a
symbol
* If that succeeds, that function is called as a handler for the current request
Only public functions in existing namespaces in the /{appname}/controllers
folder will resolve to match inbound requests.
FW/1 locates views and a cascade of optional layout wrappers via convention
too. There are also "before" and "after" extension points for pre- and
post-processing to occur application-wide and/or per-controller. You can also
specify some explicit routes that should map differently (basic but standard
routing with :name style placeholders — explicit routes are currently
undocumented as they’re a work-in-progress).
A simple "user manager" example is here:
https://github.com/framework-one/fw1-clj/tree/master/examples/usermanager
<https://github.com/framework-one/fw1-clj/tree/master/examples/usermanager>
As indicated in the original thread, a lot of people have built substantial
production apps with FW/1 in its original language. It’s hit a particular sweet
spot for a lot of people in being really easy to get up and running with, but
useful enough to build serious business apps. Right now, no one is using this
Clojure port (except me, mostly for fun). That’s why I haven’t promoted it here
(beyond a few passing mentions).
There’s a Leiningen template:
lein new fw1 tryme
cd tryme
PORT=8321 lein run
go to http://localhost:8321/
Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.