Skip to content

ska2342/ring-routes-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ring And Compojure Routes Demo

Demo for some of the less common usage patterns of Clojure Ring.

Most tutorials on ring and compojure out there just show you how to set up a few routes and then push your complete app through some middleware to get going.

This demo outlines some patterns for the following use-cases:

  • Plain basic serving of responses without any magic.
  • Serving static files from unusual places and with custom URIs.
  • Serving a static robot.txt
  • Using a compojure context.
  • Calling out to functions defining the routes outside of the common defroutes macro.
  • Wrapping only some of your routes into some ring middleware.
  • Using selective wrapping to add HTTP basic auth with buddy.
  • A slightly more contrived example how to add buddy session handling to allow logging in and in the background protect some API calls with the same session.

Run the Demo

This project does not have any main methods that allow you to run the code easily.

I expect you to be familiar with your Clojure IDE. For me, just opening one of the sources files and run M-x cider-jack-in in my Emacs works well.

Actually, this project does not have to be run at all. It should serve as an inspiration for you how to organize your routes and middleware when your application starts to grow.

License

Copyright © 2016 Stefan Kamphausen

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

Demo for some of the less common usage patterns of Clojure Ring

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published