Book Image

Clojure Web Development Essentials

By : Ryan Baldwin
Book Image

Clojure Web Development Essentials

By: Ryan Baldwin

Overview of this book

Table of Contents (19 chapters)
Clojure Web Development Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Restricted routes


Restricting access to a specific web page or some functionality is a cornerstone of today's web apps. Without restricting resources or functionality, the applications that power the Internet would be in complete anarchy. Anybody could post as anybody on Twitter; Facebook would suddenly have 1 single user representing 1/7th of the world's population; YouTube would become even more dominated by cats. Hence, restricting access is a good thing – even if you wish YouTube was dominated (even more so) by cats.

Restricting routes in a Luminus application is a two pronged approach. First, we must mark a route as restricted. Secondly, we must define what governs access to the restricted route.

Restricting route access

There are two ways we can restrict route access in a Luminus app. The first is by using the noir.util.route/restricted macro on the route in question. For example, pretend we had the following route:

(GET "/just-for-you" [] (render-private-page))

That's something we've seen...