This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-09
Channels
- # announcements (14)
- # architecture (42)
- # babashka (23)
- # beginners (37)
- # biff (8)
- # calva (2)
- # cider (3)
- # clara (42)
- # clerk (14)
- # clojure (55)
- # clojure-brasil (3)
- # clojure-dev (5)
- # clojure-europe (18)
- # clojure-hungary (88)
- # clojure-losangeles (3)
- # clojure-nl (1)
- # clojure-norway (66)
- # clojure-uk (9)
- # clojurescript (16)
- # core-logic (16)
- # datomic (6)
- # fulcro (32)
- # hyperfiddle (25)
- # instaparse (12)
- # joyride (2)
- # lsp (13)
- # malli (15)
- # off-topic (50)
- # polylith (11)
- # portal (3)
- # re-frame (2)
- # reitit (2)
- # sci (8)
- # shadow-cljs (16)
- # tools-deps (13)
- # xtdb (5)
This is a similar sort of question to https://clojurians.slack.com/archives/C7YF1SBT3/p1698852178160519 and I thought I'd start off in here rather than launching straight into an issue on GitHub. I'm aiming for a GCP-style API POST
where the API can specify 'commands' against a resource with a colon prefix. I've switched the router :syntax
to :bracket
and it's working for some parts of my API. However, I've hit one particular combination of routes which doesn't seem to work.
I think I've distilled the issue I'm seeing into the following example in the thread and I'd really appreciate some advice.
(ns my-namespace
(:require [reitit.core :as r]))
(def routes
["/a/{b}"
["/c"]
[":d"]])
(r/router
routes
{:conflicts (constantly nil) ;; doesn't suppress conflict error
:syntax :bracket})
; Execution error (ExceptionInfo) at reitit.exception/exception (exception.cljc:19).
; :reitit.trie/multiple-terminators
;
; {:terminators ("/c" ":d"), :path "/a/{b}"}
(r/router
routes
{:conflicts (constantly nil) ;; suppresses conflict error
:syntax :colon})
(r/router
routes
{:conflicts (constantly nil)}) ;; doesn't suppress conflict error
; Execution error (ExceptionInfo) at reitit.exception/exception (exception.cljc:19) .
; :reitit.trie/following-parameters
;
; {:path "/a/{b}:d", :parameters (:b :d)}
I think there are a couple of problems here. The first is that I'm getting a conflict error. I feel like if I've switched to :bracket
syntax the :d
should be recognised as a literal rather than a parameter (if that's what's even happening here) so it should be valid.
The second is that I don't seem to be able to suppress the conflict error using the conflicts
option. It doesn't seem to work when I'm using :colon
syntax but not if :bracket
is used.
If anyone is able to shed some light on whether I've misunderstood something I'd be very grateful!