Skip to content

Commit

Permalink
Merge pull request #142 from sig-gis/HER-648-pnguyen-remove-unnecessa…
Browse files Browse the repository at this point in the history
…ry-config

Removing :truncate-request? from server config
  • Loading branch information
lambdatronic authored Sep 5, 2024
2 parents e57075c + 6089c7a commit 97c8767
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 10 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
7 changes: 2 additions & 5 deletions 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 All @@ -45,14 +44,13 @@
(defn start-server!
"See README.org -> Web Framework -> triangulum.server for details."
[{:keys [http-port https-port nrepl cider-nrepl nrepl-bind nrepl-port mode log-dir
truncate-request? handler workers keystore-file keystore-type keystore-password]
handler workers keystore-file keystore-type keystore-password]
:or {nrepl-bind "127.0.0.1"
nrepl-port 5555
keystore-file "./.key/keystore.pkcs12"
keystore-type "pkcs12"
keystore-password "foobar"
log-dir ""
truncate-request? true
mode "prod"}}]
(let [has-key? (and keystore-file (.exists (io/file keystore-file)))
ssl? (and has-key? https-port)
Expand All @@ -61,8 +59,7 @@
(create-handler-stack ssl? reload?))
config (merge
{:port http-port
:join? false
:truncate-request? truncate-request?}
:join? false}
(when ssl?
{:ssl? true
:ssl-port https-port
Expand Down

0 comments on commit 97c8767

Please sign in to comment.