mirror of
https://github.com/penpot/penpot.git
synced 2025-05-10 07:56:38 +02:00
✨ Add more parameters to the http server module.
This commit is contained in:
parent
9688bd8408
commit
c99f571296
3 changed files with 19 additions and 10 deletions
|
@ -5,11 +5,12 @@
|
||||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
;; defined by the Mozilla Public License, v. 2.0.
|
;; defined by the Mozilla Public License, v. 2.0.
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2020 UXBOX Labs SL
|
;; Copyright (c) 2020-2021 UXBOX Labs SL
|
||||||
|
|
||||||
(ns app.http
|
(ns app.http
|
||||||
(:require
|
(:require
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
|
[app.common.data :as d]
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.http.auth :as auth]
|
[app.http.auth :as auth]
|
||||||
[app.http.errors :as errors]
|
[app.http.errors :as errors]
|
||||||
|
@ -26,14 +27,20 @@
|
||||||
(s/def ::handler fn?)
|
(s/def ::handler fn?)
|
||||||
(s/def ::ws (s/map-of ::us/string fn?))
|
(s/def ::ws (s/map-of ::us/string fn?))
|
||||||
(s/def ::port ::cfg/http-server-port)
|
(s/def ::port ::cfg/http-server-port)
|
||||||
|
(s/def ::name ::us/string)
|
||||||
|
|
||||||
(defmethod ig/pre-init-spec ::server [_]
|
(defmethod ig/pre-init-spec ::server [_]
|
||||||
(s/keys :req-un [::handler ::port]
|
(s/keys :req-un [::handler ::port]
|
||||||
:opt-un [::ws]))
|
:opt-un [::ws ::name]))
|
||||||
|
|
||||||
|
(defmethod ig/prep-key ::server
|
||||||
|
[_ cfg]
|
||||||
|
(merge {:name "http"}
|
||||||
|
(d/without-nils cfg)))
|
||||||
|
|
||||||
(defmethod ig/init-key ::server
|
(defmethod ig/init-key ::server
|
||||||
[_ {:keys [handler ws port] :as opts}]
|
[_ {:keys [handler ws port name] :as opts}]
|
||||||
(log/infof "Starting http server on port %s." port)
|
(log/infof "Starting %s server on port %s." name port)
|
||||||
(let [options (merge
|
(let [options (merge
|
||||||
{:port port
|
{:port port
|
||||||
:h2c? true
|
:h2c? true
|
||||||
|
@ -47,11 +54,12 @@
|
||||||
(.setServer server))]
|
(.setServer server))]
|
||||||
|
|
||||||
(.setErrorHandler server handler)
|
(.setErrorHandler server handler)
|
||||||
server))
|
|
||||||
|
(assoc opts :server server)))
|
||||||
|
|
||||||
(defmethod ig/halt-key! ::server
|
(defmethod ig/halt-key! ::server
|
||||||
[_ server]
|
[_ {:keys [server name port] :as opts}]
|
||||||
(log/info "Stoping http server.")
|
(log/infof "Stoping %s server on port %s." name port)
|
||||||
(.stop server))
|
(.stop server))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
;; defined by the Mozilla Public License, v. 2.0.
|
;; defined by the Mozilla Public License, v. 2.0.
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2020 UXBOX Labs SL
|
;; Copyright (c) 2020-2021 UXBOX Labs SL
|
||||||
|
|
||||||
(ns app.main
|
(ns app.main
|
||||||
(:require
|
(:require
|
||||||
|
@ -198,7 +198,8 @@
|
||||||
|
|
||||||
:app.telemetry/server
|
:app.telemetry/server
|
||||||
{:port (:telemetry-server-port config 6063)
|
{:port (:telemetry-server-port config 6063)
|
||||||
:handler (ig/ref :app.telemetry/handler)}})))
|
:handler (ig/ref :app.telemetry/handler)
|
||||||
|
:name "telemetry"}})))
|
||||||
|
|
||||||
|
|
||||||
(defmethod ig/init-key :default [_ data] data)
|
(defmethod ig/init-key :default [_ data] data)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
;; defined by the Mozilla Public License, v. 2.0.
|
;; defined by the Mozilla Public License, v. 2.0.
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2020 UXBOX Labs SL
|
;; Copyright (c) 2020-2021 UXBOX Labs SL
|
||||||
|
|
||||||
(ns app.telemetry
|
(ns app.telemetry
|
||||||
(:require
|
(:require
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue