Skip to content

Commit

Permalink
Review fixes: see below for details
Browse files Browse the repository at this point in the history
* Global
- Rename `:truncate-request?` to `:truncate-request` everywhere

* README.org
- Make `:truncate-request` false by default (more intuitive)

* config.namespaced-example.edn
- Add example for `:triangulum.handler/truncate-request`

* config.nested-example.edn
- Add example for `:server` -> `:truncate-request`

* src/triangulum/config.clj
- 27: `::boolean` spec is unused

* src/triangulum/config_namespaced_spec.clj
- 36: Include `:triangulum.handler/truncate-request` in server spec

* src/triangulum/config_nested_spec.clj
- 23: Include `:triangulum.handler/truncate-request` in server spec

* src/triangulum/handler.clj
- 38: Add spec: `::truncate-request boolean?`
- Change :truncate-request logic to be false by default (more intuitive)

* src/triangulum/server.clj
- 28: Remove `::truncate-request` spec
  • Loading branch information
Gary Johnson committed Sep 4, 2024
1 parent eea93ee commit 6089c7a
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.org
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ file logging system, and worker functions for non-HTTP-related tasks.
:cider-nrepl true ; If your editor supports CIDER middleware
:mode "dev" ; or prod
:log-dir "logs" ; or "" for stdout
:truncate-request? false ; true by default
:truncate-request true ; false by default
:handler product-ns.routing/handler
:workers {:scheduler {:start product-ns.jobs/start-scheduled-jobs!
:stop product-ns.jobs/stop-scheduled-jobs!}}
Expand Down
1 change: 1 addition & 0 deletions config.namespaced-example.edn
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
:triangulum.handler/route-authenticator product-ns.handlers/route-authenticator
:triangulum.handler/routing-tables [backend-libary-ns.routing/routes product-ns.routing/routes]
:triangulum.handler/bad-tokens #{".php"}
:triangulum.handler/truncate-request false
:triangulum.handler/private-request-keys #{:base64Image :plotFileBase64 :sampleFileBase64}
:triangulum.handler/private-response-keys #{}

Expand Down
1 change: 1 addition & 0 deletions config.nested-example.edn
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
:route-authenticator product-ns.handlers/route-authenticator
:routing-tables [common-libary-ns.routing/routes product-ns.routing/routes]
:bad-tokens #{".php"}
:truncate-request false
:private-request-keys #{:base64Image :plotFileBase64 :sampleFileBase64}
:private-response-keys #{}

Expand Down
1 change: 0 additions & 1 deletion src/triangulum/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
(s/def ::url-or-file-path (s/and string? #(re-matches #"^(https?:\/\/[^\s\/$.?#].[^\s]*)|(/[^:*?\"<>|]*)$" %)))
(s/def ::path (s/and string? #(re-matches #"[./][^:*?\"<>|]*" %)))
(s/def ::hostname (s/and string? #(re-matches #"[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}" %)))
(s/def ::boolean boolean?)

;; Config file

Expand Down
1 change: 1 addition & 0 deletions src/triangulum/config_namespaced_spec.clj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
:triangulum.handler/redirect-handler
:triangulum.handler/route-authenticator
:triangulum.handler/routing-tables
:triangulum.handler/truncate-request
:triangulum.handler/private-request-keys
:triangulum.handler/private-response-keys
:triangulum.handler/bad-tokens
Expand Down
1 change: 1 addition & 0 deletions src/triangulum/config_nested_spec.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
:triangulum.handler/route-authenticator
:triangulum.handler/routing-tables
:triangulum.handler/bad-tokens
:triangulum.handler/truncate-request
:triangulum.handler/private-request-keys
:triangulum.handler/private-response-keys
:triangulum.worker/workers
Expand Down
5 changes: 2 additions & 3 deletions src/triangulum/handler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
(s/def ::route-authenticator ::config/namespaced-symbol)
(s/def ::routing-tables (s/coll-of ::config/namespaced-symbol))
(s/def ::bad-tokens (s/coll-of ::config/string :kind set? :min-count 0))
(s/def ::truncate-request boolean?)
(s/def ::private-request-keys (s/coll-of keyword :kind set?))
(s/def ::private-response-keys (s/coll-of keyword :kind set?))

Expand Down Expand Up @@ -85,11 +86,9 @@
[handler]
(fn [request]
(let [{:keys [uri request-method params]} request
truncate-request? (get-config :server :truncate-request)
private-request-keys (or (get-config :server :private-request-keys)
#{:password :passwordConfirmation})
truncate-request? (if (some? (get-config :server :truncate-request?))
(get-config :server :truncate-request?)
true)
param-str (pr-str (apply dissoc params private-request-keys))]
(log (apply str "Request(" (name request-method) "): \"" uri "\" " param-str) :truncate? truncate-request?)
(handler request))))
Expand Down
1 change: 0 additions & 1 deletion src/triangulum/server.clj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
(s/def ::cider-nrepl boolean?)
(s/def ::mode (s/and ::config/string #{"dev" "prod"}))
(s/def ::log-dir ::config/string)
(s/def ::truncate-request? ::config/boolean)
(s/def ::handler ::config/namespaced-symbol)
(s/def ::keystore-file ::config/string)
(s/def ::keystore-type ::config/string)
Expand Down

0 comments on commit 6089c7a

Please sign in to comment.