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