Ring-style middleware for Jira REST API requests.
Ring-style middleware for Jira REST API requests.
(wrap-api)
(wrap-api host)
Creates a Ring-style middleware that configures a request map to make it work with Jira REST API.
Arguments
host
Hostname of the Jira instance to connect to. It can be nil
. In this case
the function will look for ::jira-host
key in the request map.
Creates a [Ring-style] middleware that configures a request map to make it work with Jira REST API. **Arguments** **`host`** Hostname of the Jira instance to connect to. It can be `nil`. In this case the function will look for `::jira-host` key in the request map. [Ring-style]: https://github.com/ring-clojure/ring/blob/master/SPEC
(wrap-token-auth)
(wrap-token-auth email token)
Creates a Ring-style middleware that configures a request map to use Basic auth for REST APIs.
Arguments
email
Atlassian account email address. Can be nil
.
token
Atlassian API token. Can be nil
.
If either of email
or token
is nil
, the function will look for
::jira-email
and ::jira-token
keys respectively in the request map and use
their values instead.
The middleware adds :basic-auth
key to the request map and you
have to use it to setup basic HTTP auth headers somewhere later by
yourself or using corresponding middleware from HTTP client library
you use. For example, for clj-http you can do this:
(ns manenko.clj-jira.example
(:require [clj-http.client :as client]
[manenko.clj-jira.core :as jira]
[manenko.clj-jira.middleware :as middleware]))
,,,
(client/with-middleware
(conj
client/default-middleware
(middleware/wrap-api host)
(middleware/wrap-token-auth email token))
(client/request m))
The clj-http.client/default-middleware
var includes
clj-http.client/wrap-basic-auth
middleware which looks for
:basic-auth
key in a request map and configures the request for
basic HTTP authentication.
Creates a [Ring-style] middleware that configures a request map to use [Basic auth for REST APIs]. **Arguments** **`email`** Atlassian account email address. Can be `nil`. **`token`** Atlassian [API token]. Can be `nil`. If either of `email` or `token` is `nil`, the function will look for `::jira-email` and `::jira-token` keys respectively in the request map and use their values instead. The middleware adds `:basic-auth` key to the request map and you have to use it to setup basic HTTP auth headers somewhere later by yourself or using corresponding middleware from HTTP client library you use. For example, for [clj-http] you can do this: ```clojure (ns manenko.clj-jira.example (:require [clj-http.client :as client] [manenko.clj-jira.core :as jira] [manenko.clj-jira.middleware :as middleware])) ,,, (client/with-middleware (conj client/default-middleware (middleware/wrap-api host) (middleware/wrap-token-auth email token)) (client/request m)) ``` The `clj-http.client/default-middleware` var includes `clj-http.client/wrap-basic-auth` middleware which looks for `:basic-auth` key in a request map and configures the request for basic HTTP authentication. [Basic auth for REST APIs]: https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-basic-authentication/ [API token]: https://confluence.atlassian.com/cloud/api-tokens-938839638.html [Ring-style]: https://github.com/ring-clojure/ring/blob/master/SPEC [clj-http]: https://github.com/dakrone/clj-http
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close