Fix build errors + problem with webhook routes
* remove unnecessary servlet context middleware * do not apply unnecessary ring middleware to webhook routes
This commit is contained in:
parent
9b972625e0
commit
f383ab9a0d
|
@ -19,18 +19,20 @@
|
|||
|
||||
(def app-routes
|
||||
(routes
|
||||
(-> #'home-routes
|
||||
(wrap-routes middleware/wrap-csrf)
|
||||
(wrap-routes middleware/wrap-formats))
|
||||
#'redirect-routes
|
||||
#'webhook-routes
|
||||
#'service-routes
|
||||
#'qr-routes
|
||||
(route/not-found
|
||||
(middleware/wrap-base
|
||||
(routes
|
||||
(-> #'home-routes
|
||||
(wrap-routes middleware/wrap-csrf)
|
||||
(wrap-routes middleware/wrap-formats))
|
||||
#'redirect-routes
|
||||
#'service-routes
|
||||
#'qr-routes
|
||||
(route/not-found
|
||||
(:body
|
||||
(error-page {:status 404
|
||||
:title "page not found"})))))
|
||||
(error-page {:status 404
|
||||
:title "page not found"})))))))
|
||||
|
||||
|
||||
(defn app []
|
||||
(middleware/wrap-base #'app-routes))
|
||||
#'app-routes)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(ns commiteth.middleware
|
||||
(:require [commiteth.env :refer [defaults]]
|
||||
[clojure.tools.logging :as log]
|
||||
[commiteth.layout :refer [*app-context* error-page]]
|
||||
[commiteth.layout :refer [error-page]]
|
||||
[ring.middleware.anti-forgery :refer [wrap-anti-forgery]]
|
||||
[ring.middleware.format :refer [wrap-restful-format]]
|
||||
[commiteth.config :refer [env]]
|
||||
|
@ -12,24 +12,9 @@
|
|||
[buddy.auth.middleware :refer [wrap-authentication wrap-authorization]]
|
||||
[buddy.auth.backends.session :refer [session-backend]]
|
||||
[buddy.auth.accessrules :refer [restrict]]
|
||||
[buddy.auth :refer [authenticated?]]
|
||||
[commiteth.layout :refer [*identity*]])
|
||||
(:import [javax.servlet ServletContext]))
|
||||
[buddy.auth :refer [authenticated?]]))
|
||||
|
||||
(defn wrap-context [handler]
|
||||
(fn [request]
|
||||
(binding [*app-context*
|
||||
(if-let [context (:servlet-context request)]
|
||||
;; If we're not inside a servlet environment
|
||||
;; (for example when using mock requests), then
|
||||
;; .getContextPath might not exist
|
||||
(try (.getContextPath ^ServletContext context)
|
||||
(catch IllegalArgumentException _ context))
|
||||
;; if the context is not specified in the request
|
||||
;; we check if one has been specified in the environment
|
||||
;; instead
|
||||
(:app-context env))]
|
||||
(handler request))))
|
||||
(declare ^:dynamic *identity*)
|
||||
|
||||
(defn wrap-internal-error [handler]
|
||||
(fn [req]
|
||||
|
@ -89,6 +74,5 @@
|
|||
(-> site-defaults
|
||||
(assoc-in [:security :anti-forgery] false)
|
||||
(dissoc :session)))
|
||||
wrap-context
|
||||
wrap-gzip
|
||||
wrap-internal-error))
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
[commiteth.db.bounties :as bounties]
|
||||
[commiteth.db.comment-images :as comment-images]
|
||||
[commiteth.github.core :as github]
|
||||
[clojure.tools.logging :as log]
|
||||
[clojure.java.io :as io])
|
||||
[clojure.tools.logging :as log])
|
||||
(:import [java.io ByteArrayInputStream]))
|
||||
|
||||
|
||||
|
|
|
@ -152,9 +152,10 @@
|
|||
(let [raw-payload (slurp body)
|
||||
payload (json/parse-string raw-payload true)]
|
||||
(if (validate-secret payload raw-payload (get headers "x-hub-signature"))
|
||||
(do (log/debug "Github secret validation OK")
|
||||
(log/debug "x-github-event" (get headers "x-github-event"))
|
||||
(case (get headers "x-github-event")
|
||||
"issues" (handle-issue payload)
|
||||
"pull_request" (handle-pull-request payload)
|
||||
(ok)))))))
|
||||
(do
|
||||
(log/debug "Github secret validation OK")
|
||||
(log/debug "x-github-event" (get headers "x-github-event"))
|
||||
(case (get headers "x-github-event")
|
||||
"issues" (handle-issue payload)
|
||||
"pull_request" (handle-pull-request payload)
|
||||
(ok)))))))
|
||||
|
|
Loading…
Reference in New Issue