Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
[org.clojure/core.async "0.2.374"]
;; the following two entries are to support sqlite
[org.clojure/java.jdbc "0.3.7"]
[org.xerial/sqlite-jdbc "3.8.9"]]
[org.xerial/sqlite-jdbc "3.8.9"]
[ring-cors "0.1.8"]]
:main ^:skip-aot zimbra.simioj.main
:target-path "target/%s"
:profiles {:uberjar {:aot :all}
Expand Down
6 changes: 5 additions & 1 deletion resources/defaults.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
:name "node0"
;; Inter-node communications
:endpoint {;; HTTP address:port to bind to
:http "0.0.0.0:2283"}
:http "0.0.0.0:2283"
;; CORS
:access-control-allow-origin [".*"]
:access-control-allow-methods [:get :post]
}
;; Jetty configuration
:worker {:count 4 :threads 4}
;; This location is added to the classpath and should contain
Expand Down
11 changes: 9 additions & 2 deletions src/zimbra/simioj/endpoint/http.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[compojure.core :refer :all]
[ring.adapter.jetty :refer [run-jetty]]
[ring.util.request :refer :all]
[ring.middleware.cors :refer [wrap-cors]]
[zimbra.simioj.endpoint.middleware :refer :all]
[zimbra.simioj.raft.server :refer :all])
(:gen-class))
Expand Down Expand Up @@ -145,9 +146,15 @@ POST <command> - Post a command to the Raft
(defn- endpoint-app
"Wraps the provided routes with json or edn filtering"
[ctx]
(wrap-response
(wrap-cors
(wrap-response
(routes
(app-routes ctx))))
(app-routes ctx)))
:access-control-allow-origin
(map re-pattern
(get-in @ctx [:config :node :endpoint :access-control-allow-origin] ".*"))
:access-control-allow-methods
(get-in @ctx [:config :node :endpoint :access-control-allow-methods] [:get :post])))


(defn start!
Expand Down