This commit is contained in:
@@ -57,26 +57,20 @@
|
|||||||
(def router
|
(def router
|
||||||
(reitit.ring/router
|
(reitit.ring/router
|
||||||
#{["/" {:get hello}]
|
#{["/" {:get hello}]
|
||||||
["/n/:slug" {:get
|
["/n/:slug"
|
||||||
{:handler node-by-slug
|
{:get {:handler node-by-slug
|
||||||
:parameters
|
:parameters
|
||||||
{:path {:slug (st/spec {:spec ::slug/slug})}}}}]
|
{:path {:slug ::slug/slug}}}}]
|
||||||
["/id/:id" {:get node-by-id}]}
|
["/id/:id" {:get node-by-id}]}
|
||||||
{:validate reitit.spec/validate
|
{:validate reitit.spec/validate
|
||||||
:exception reitit.dev.pretty/exception
|
:exception reitit.dev.pretty/exception
|
||||||
:spec (s/merge :reitit.spec/default-data)
|
:spec (s/merge :reitit.spec/default-data)
|
||||||
#_#_
|
|
||||||
:reitit.spec/wrap spec-tools.spell/closed
|
|
||||||
#_#_:compile reitit.coercion/compile-request-coercers
|
|
||||||
:data
|
:data
|
||||||
{:coercion reitit.coercion.spec/coercion
|
{:coercion reitit.coercion.spec/coercion
|
||||||
:middleware [reitit.ring.middleware.exception/exception-middleware
|
:middleware [reitit.ring.middleware.exception/exception-middleware
|
||||||
reitit.ring.coercion/coerce-request-middleware
|
reitit.ring.coercion/coerce-request-middleware
|
||||||
reitit.ring.coercion/coerce-response-middleware]}}))
|
reitit.ring.coercion/coerce-response-middleware
|
||||||
|
#_reitit.ring.coercion/coerce-exceptions-middleware]}}))
|
||||||
(defn match-by-path-and-coerce! [path]
|
|
||||||
(if-let [match (r/match-by-path router path)]
|
|
||||||
(assoc match :parameters (reitit.coercion/coerce! match))))
|
|
||||||
|
|
||||||
|
|
||||||
;;; Server API
|
;;; Server API
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
(ns net.deertopia.publisher.slug
|
(ns net.deertopia.publisher.slug
|
||||||
(:require [clojure.spec.alpha :as s])
|
(:require [clojure.spec.alpha :as s]
|
||||||
|
[spec-tools.core :as st])
|
||||||
(:import (java.nio ByteBuffer)
|
(:import (java.nio ByteBuffer)
|
||||||
(java.util Base64 UUID)))
|
(java.util Base64 UUID)))
|
||||||
|
|
||||||
@@ -47,11 +48,11 @@
|
|||||||
(let [decoder (Base64/getUrlDecoder)]
|
(let [decoder (Base64/getUrlDecoder)]
|
||||||
(bytes->uuid (.decode decoder (str slug)))))
|
(bytes->uuid (.decode decoder (str slug)))))
|
||||||
|
|
||||||
#_
|
(comment
|
||||||
(let [uuid #uuid "f9eab66e-7773-4b87-b854-0bfc8f563809"
|
(let [uuid #uuid "f9eab66e-7773-4b87-b854-0bfc8f563809"
|
||||||
slug (from-uuid uuid)
|
slug (from-uuid uuid)
|
||||||
round-tripped (to-uuid slug)]
|
round-tripped (to-uuid slug)]
|
||||||
{:uuid uuid, :slug slug, :round-tripped round-tripped})
|
{:uuid uuid, :slug slug, :round-tripped round-tripped}))
|
||||||
|
|
||||||
(defn make-slug [string]
|
(defn make-slug [string]
|
||||||
(assert (try (to-uuid string)
|
(assert (try (to-uuid string)
|
||||||
|
|||||||
Reference in New Issue
Block a user