Skip to content
Snippets Groups Projects
Commit c231eabe authored by Cam Saül's avatar Cam Saül
Browse files

Don't need 2 different HTTP libs :scream_cat:

parent 048e50eb
No related branches found
No related tags found
No related merge requests found
......@@ -20,11 +20,10 @@
[org.clojure/tools.namespace "0.2.10"]
[amalloy/ring-gzip-middleware "0.1.3"] ; Ring middleware to GZIP responses if client can handle it
[cheshire "5.5.0"] ; fast JSON encoding (used by Ring JSON middleware)
[clj-http "0.3.0"
[clj-http "2.1.0" ; HTTP client
:exclusions [commons-codec
commons-io
slingshot]]
[clj-http-lite "0.3.0"] ; HTTP client; lightweight version of clj-http that uses HttpURLConnection instead of Apache
[clj-time "0.11.0"] ; library for dealing with date/time
[clojurewerkz/quartzite "2.0.0"] ; scheduling library
[colorize "0.1.1" :exclusions [org.clojure/clojure]] ; string output with ANSI color codes (for logging)
......@@ -35,7 +34,7 @@
ring/ring-core]]
[com.draines/postal "1.11.4"] ; SMTP library
[com.google.apis/google-api-services-bigquery ; Google BigQuery Java Client Library
"v2-rev262-1.21.0"]
"v2-rev270-1.21.0"]
[com.h2database/h2 "1.4.191"] ; embedded SQL database
[com.mattbertolini/liquibase-slf4j "2.0.0"] ; Java Migrations lib
[com.novemberain/monger "3.0.2"] ; MongoDB Driver
......@@ -48,7 +47,7 @@
javax.jms/jms
com.sun.jdmk/jmxtools
com.sun.jmx/jmxri]]
[medley "0.7.1"] ; lightweight lib of useful functions
[medley "0.7.2"] ; lightweight lib of useful functions
[mysql/mysql-connector-java "5.1.38"] ; MySQL JDBC driver
[net.sf.cssbox/cssbox "4.10"
:exclusions [org.slf4j/slf4j-api]]
......@@ -56,7 +55,7 @@
[org.xhtmlrenderer/flying-saucer-core "9.0.8"]
[org.liquibase/liquibase-core "3.4.2"] ; migration management (Java lib)
[org.slf4j/slf4j-log4j12 "1.7.16"]
[org.yaml/snakeyaml "1.16"] ; YAML parser (required by liquibase)
[org.yaml/snakeyaml "1.17"] ; YAML parser (required by liquibase)
[org.xerial/sqlite-jdbc "3.8.11.2"] ; SQLite driver
[postgresql "9.3-1102.jdbc41"] ; Postgres driver
[prismatic/schema "1.0.5"] ; Data schema declaration and validation library
......@@ -87,7 +86,7 @@
:exclusions [org.clojure/clojure]] ; Linting
[lein-ancient "0.6.8" ; Check project for outdated dependencies + plugins w/ 'lein ancient'
:exclusions [org.clojure/clojure]]
[lein-bikeshed "0.2.0"] ; Linting
[lein-bikeshed "0.3.0"] ; Linting
[lein-expectations "0.0.8"] ; run unit tests with 'lein expectations'
[lein-instant-cheatsheet "2.1.5" ; use awesome instant cheatsheet created by yours truly w/ 'lein instant-cheatsheet'
:exclusions [org.clojure/clojure
......
(ns metabase.integrations.slack
(:require [cheshire.core :as cheshire]
[clj-http.lite.client :as client]
[clj-http.client :as http]
[clojure.tools.logging :as log]
[metabase.models.setting :refer [defsetting]]))
......@@ -22,15 +21,15 @@
(defn slack-api-get
"Generic function which calls a given method on the Slack api via HTTP GET."
([token method]
(slack-api-get token method {}))
(slack-api-get token method {}))
([token method params]
{:pre [(string? method)
(map? params)]}
{:pre [(string? method)
(map? params)]}
(when token
(try
(client/get (str slack-api-baseurl "/" method) {:query-params (merge params {:token token})
:conn-timeout 1000
:socket-timeout 1000})
(http/get (str slack-api-baseurl "/" method) {:query-params (merge params {:token token})
:conn-timeout 1000
:socket-timeout 1000})
(catch Throwable t
(log/warn "Error making Slack API call:" (.getMessage t)))))))
......@@ -43,9 +42,9 @@
(map? params)]}
(when token
(try
(client/post (str slack-api-baseurl "/" method) {:form-params (merge params {:token token})
:conn-timeout 1000
:socket-timeout 1000})
(http/post (str slack-api-baseurl "/" method) {:form-params (merge params {:token token})
:conn-timeout 1000
:socket-timeout 1000})
(catch Throwable t
(log/warn "Error making Slack API call:" (.getMessage t)))))))
......
(ns metabase.api.notify-test
(:require [clj-http.lite.client :as client]
(:require [clj-http.client :as client]
[expectations :refer :all]
(metabase [http-client :as http]
[middleware :as middleware])))
......
(ns metabase.http-client
"HTTP client for making API calls against the Metabase API. For test/REPL purposes."
(:require [clojure.tools.logging :as log]
[cheshire.core :as cheshire]
[clj-http.lite.client :as client]
[cheshire.core :as json]
[clj-http.client :as client]
[metabase.config :as config]
[metabase.util :as u]))
......@@ -67,7 +67,7 @@
credentials))}}
(seq http-body) (assoc
:content-type :json
:body (cheshire/generate-string http-body)))
:body (json/generate-string http-body)))
request-fn (case method
:get client/get
:post client/post
......@@ -80,14 +80,14 @@
{:keys [status body]} (try (request-fn url request-map)
(catch clojure.lang.ExceptionInfo e
(log/debug method-name url)
(:object (.getData ^clojure.lang.ExceptionInfo e))))]
(:object (ex-data e))))]
;; -check the status code if EXPECTED-STATUS was passed
(log/debug method-name url status)
(when expected-status
(when-not (= status expected-status)
(let [message (format "%s %s expected a status code of %d, got %d." method-name url expected-status status)
body (try (-> (cheshire/parse-string body)
body (try (-> (json/parse-string body)
clojure.walk/keywordize-keys)
(catch Exception _ body))]
(log/error (u/pprint-to-str 'red body))
......@@ -95,7 +95,7 @@
;; Deserialize the JSON response or return as-is if that fails
(try (-> body
cheshire/parse-string
json/parse-string
clojure.walk/keywordize-keys
auto-deserialize-dates)
(catch Exception _
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment