Fork me on GitHub
#pedestal
<
2016-01-28
>
christianromney15:01:06

re: the ::events (sorry late to the party)

christianromney15:01:22

["/events" {:get [::events (start-event-stream stream-ready)]}]

christianromney15:01:21

this maps GET requests the url ”/events” to (start-event-stream) but also names the route

christianromney15:01:49

you can have unnamed routes {:get (start-event-stream stream-ready)}

christianromney15:01:55

or named routes as above

christianromney15:01:12

you name them with a keyword that you can pass to route/url-for

christianromney15:01:43

in this case, the keyword is namespaced, hence the extra colon :

christianromney15:01:54

so assuming that file is in ns

christianromney15:01:07

(ns example.routes)

christianromney15:01:35

then ::events is shorthand for :example.routes/events

christianromney15:01:00

this allows you to use a generic word like ‘events'

christianromney15:01:05

while avoiding name clashes

christianromney15:01:57

from a hypothetically different namespace, assume you want to redirect someone to that endpoint

christianromney15:01:16

`(ns example.other (:require [io.pedestal.http.route :as route] [example.routes :as r])) … (ring/redirect (route/url-for ::r/events)) `

christianromney15:01:28

meh forgive the formatting, hopefully the idea is clear...

christianromney15:01:47

hope that helps someone