tophat.core
->cxml
(->cxml x)
Converts source XML file x or raw string XML x to interim Clojure XML representation.
->emap
(->emap em & [filtr])
->exception-info
(->exception-info e & args)
->json-str
(->json-str m)
Generate a JSON string from map m.
->transit
(->transit m)
Converts a Clojure map m to transit string.
->xml-str
(->xml-str m)
Converts a Clojure map m to XML string.
<-accept-charset
(<-accept-charset r)
<-accept-control-request-method
(<-accept-control-request-method r)
<-accept-datetime
(<-accept-datetime r)
<-accept-encoding
(<-accept-encoding r)
<-accept-language
(<-accept-language r)
<-accept-patch
(<-accept-patch r)
<-accept-ranges
(<-accept-ranges r)
<-access-control-access-origin
(<-access-control-access-origin r)
<-access-control-allow-credentials
(<-access-control-allow-credentials r)
<-access-control-allow-methods
(<-access-control-allow-methods r)
<-access-control-max-age
(<-access-control-max-age r)
<-authorization
(<-authorization r)
<-body
(<-body x)
Extracts the body of x recursively.
If the body is an HTTP response (contains :body), then recursively extract body.
<-cache-control
(<-cache-control r)
<-connection
(<-connection r)
<-content-disposition
(<-content-disposition r)
<-content-encoding
(<-content-encoding r)
<-content-language
(<-content-language r)
<-content-length
(<-content-length r)
<-content-location
(<-content-location r)
<-content-md5
(<-content-md5 r)
<-content-range
(<-content-range r)
<-content-type
(<-content-type r)
<-forwarded
(<-forwarded r)
<-if-modified-since
(<-if-modified-since r)
<-if-none-match
(<-if-none-match r)
<-if-unmodified-since
(<-if-unmodified-since r)
<-last-modified
(<-last-modified r)
<-max-forwards
(<-max-forwards r)
<-powered-by
(<-powered-by r)
<-proxy-authenticate
(<-proxy-authenticate r)
<-proxy-authorization
(<-proxy-authorization r)
<-public-key-pins
(<-public-key-pins r)
<-request-id
(<-request-id r)
<-retry-after
(<-retry-after r)
<-set-cookie
(<-set-cookie r)
<-status
(<-status d & [s])
Extracts status from document d.
<-strict-transport-security
(<-strict-transport-security r)
<-transfer-encoding
(<-transfer-encoding r)
<-user-agent
(<-user-agent r)
<-www-authenticate
(<-www-authenticate r)
<-xss-protection
(<-xss-protection r)
accept
(accept x & [hm])
Generates a request header for accept for single arguments,
Merges existing map h with accept x.
Mimetype x may be supported type keyword: :json, :edn, :html, :text, :xml, :yaml
accepted
(accepted b)
(accepted h b)
Generate HTTP response document with status ACCEPTED.
accepted?
(accepted? d)
Determines if HTTP response document d has ACCEPTED status.
accepts-edn?
(accepts-edn? req)
Determine if HTTP request req accepts EDN.
accepts-html?
(accepts-html? req)
Determine if HTTP request req accepts HTML.
accepts-json?
(accepts-json? req)
Determine if HTTP request req accepts JSON.
accepts-text?
(accepts-text? req)
Determine if HTTP request req accepts text.
accepts-transit?
(accepts-transit? req)
Determine if HTTP request r accepts Transit.
accepts-xml?
(accepts-xml? req)
Determine if HTTP request req accepts XML.
accepts-yaml?
(accepts-yaml? req)
Determine if HTTP request req accepts YAML.
accepts?
(accepts? req rgx)
Determines if HTTP request req Accept header matches mimetype regex rgx.
already-reported
(already-reported b)
(already-reported h b)
Generate HTTP response document with status ALREADY REPORTED.
already-reported?
(already-reported? d)
Determines if HTTP response document d has ALREADY REPORTED status.
assert-args
macro
(assert-args & pairs)
bad-gateway
(bad-gateway b)
(bad-gateway h b)
Generate HTTP response document with status BAD GATEWAY.
bad-gateway?
(bad-gateway? d)
Determines if HTTP response document d has BAD GATEWAY status.
bad-request
(bad-request b)
(bad-request h b)
Generate HTTP response document with status BAD REQUEST.
bad-request?
(bad-request? d)
Determines if HTTP response document d has BAD REQUEST status.
body->map
(body->map req)
Converts the body of the HTTP request document r to Clojure map.
body->text
(body->text req res)
Converts HTTP response document res body to appropriate text given the
HTTP request req Accepts header content.
body->transit
(body->transit r)
Converts HTTP response r body to transit format.
client-closed-request-status
collapse-stack-trace
(collapse-stack-trace ts)
conflict
(conflict b)
(conflict h b)
Generate HTTP response document with status CONFLICT.
conflict?
(conflict? d)
Determines if HTTP response document d has CONFLICT status.
connection-closed-without-response-status
content
(content x & [hm])
content-type
(content-type x & [hm])
Generates a request header for content-type x for single arguments,
Merges existing map h with content-type x.
Mimetype x may be supported type keyword: :json, :edn, :html, :text, :xml, :yaml
content?
(content? rr rgx)
Determines if content type of HTTP request/response document rr matches content regex rgx.
continue
(continue b)
(continue h b)
Generate HTTP response document with status CONTINUE.
continue?
(continue? d)
Determines if HTTP response document d has CONTINUE status.
created
(created b)
(created h b)
Generate HTTP response document with status CREATED.
created?
(created? d)
Determines if HTTP response document d has CREATED status.
echo
(echo r)
Echoes the request to response.
Used mostly for development sanity checks.
edn-content?
(edn-content? req)
Determines if content type of HTTP request req is EDN.
expectation-failed
(expectation-failed b)
(expectation-failed h b)
Generate HTTP response document with status EXPECTATION FAILED.
expectation-failed-status
expectation-failed?
(expectation-failed? d)
Determines if HTTP response document d has EXPECTATION FAILED status.
fail?
(fail? d)
Determine if HTTP response document has status of non-success.
failed-dependency
(failed-dependency b)
(failed-dependency h b)
Generate HTTP response document with status FAILED DEPENDENCY.
failed-dependency?
(failed-dependency? d)
Determines if HTTP response document d has FAILED DEPENDENCY status.
forbidden
(forbidden b)
(forbidden h b)
Generate HTTP response document with status FORBIDDEN.
forbidden?
(forbidden? d)
Determines if HTTP response document d has FORBIDDEN status.
found
(found b)
(found h b)
Generate HTTP response document with status FOUND.
found?
(found? d)
Determines if HTTP response document d has FOUND status.
gateway-timeout
(gateway-timeout b)
(gateway-timeout h b)
Generate HTTP response document with status GATEWAY TIMEOUT.
gateway-timeout?
(gateway-timeout? d)
Determines if HTTP response document d has GATEWAY TIMEOUT status.
get-params
(get-params qps)
Extracts parameters from query parameter string.
ex. (get-parameters "foo=bar&baz=23&ans=42") => {:foo "bar" :baz "23" :ans "42"}
get-scheme
(get-scheme l)
Extracts the protocol from a link string.
get-status-code
(get-status-code c)
Returns status numeric code given keyword status key c.
get-status-code-text
(get-status-code-text c)
Returns statue text given a keyword status key c.
gone
(gone b)
(gone h b)
Generate HTTP response document with status GONE.
gone?
(gone? d)
Determines if HTTP response document d has GONE status.
http-version-not-supported
(http-version-not-supported b)
(http-version-not-supported h b)
Generate HTTP response document with status HTTP VERSION NOT SUPPORTED.
http-version-not-supported-status
http-version-not-supported?
(http-version-not-supported? d)
Determines if HTTP response document d has HTTP VERSION NOT SUPPORTED status.
if-let-ok
macro
added in 1.0
(if-let-ok bindings then)
(if-let-ok bindings then else & oldform)
bindings => binding-form test
If test is true, evaluates then with binding-form bound to the value of
test, if not, yields else
im-a-teapot
(im-a-teapot b)
(im-a-teapot h b)
Generate HTTP response document with status I'M A TEAPOT.
im-a-teapot?
(im-a-teapot? d)
Determines if HTTP response document d has I'M A TEAPOT status.
im-used
(im-used b)
(im-used h b)
Generate HTTP response document with status IM USED.
im-used?
(im-used? d)
Determines if HTTP response document d has IM USED status.
insufficient-storage
(insufficient-storage b)
(insufficient-storage h b)
Generate HTTP response document with status INSUFFICIENT STORAGE.
insufficient-storage-status
insufficient-storage?
(insufficient-storage? d)
Determines if HTTP response document d has INSUFFICIENT STORAGE status.
internal-server-error
(internal-server-error b)
(internal-server-error h b)
Generate HTTP response document with status INTERNAL SERVER ERROR.
internal-server-error-key
internal-server-error-status
internal-server-error?
(internal-server-error? d)
Determines if HTTP response document d has INTERNAL SERVER ERROR status.
json-content?
(json-content? req)
Determines if content type of HTTP request req is JSON.
length-required
(length-required b)
(length-required h b)
Generate HTTP response document with status LENGTH REQUIRED.
length-required?
(length-required? d)
Determines if HTTP response document d has LENGTH REQUIRED status.
lift
Lifts function to HTTP response with default options.
lift-custom
(lift-custom options f & args)
Lifts a function f with options arguments args using options map to handle processing.
options map:
{:non-nil-response-status :$valid-http-status-code ; defaults to 200 (OK)
:result-handler-f :$function-with-result-options-f-args-parameters ; if none, pass thru non-nil result as :body
:nil-response-status :$valid-http-status-code ; defaults to 404 (Not Found)
:nil-response-body :$scalar-value-for-nil-responses ; if this is non-nil, uses this and ignores :nil-result-handler-f
:nil-result-handler-f :$function-with-options-f-args-parameters ; if none, sets :body in response to nil
:exception-status :$valid-http-status-code ; defaults to 500 (Internal Server Error)
:exception-body-f :$function-with-exception-options-f-args ; defaults to distilled exception map ->exception-info
}
Example functions:
:result-handler-f
(fn [r & _] (str "Converts result to string and ignores options, f, and args: " r))
(fn [r options f args] {:result r :options options :f f :args args})
:nil-result-handler-f
(fn [& _] "Result is nil.") ; same as using the :nil-response-body "Result is nil." in options
(fn [options f args] {:options options :f f :args args :message "Result was nil."})
:exception-body-f
(fn [e & _] (.getMessage e)) ; just sets response :body to exception message
(fn [e options f args] (str "Exception occurred with options: " options ", f " f ", args " args " [" e "]))
locked
(locked b)
(locked h b)
Generate HTTP response document with status LOCKED.
locked?
(locked? d)
Determines if HTTP response document d has LOCKED status.
loop-detected
(loop-detected b)
(loop-detected h b)
Generate HTTP response document with status LOOP DETECTED.
loop-detected?
(loop-detected? d)
Determines if HTTP response document d has LOOP DETECTED status.
method-not-allowed
(method-not-allowed b)
(method-not-allowed h b)
Generate HTTP response document with status METHOD NOT ALLOWED.
method-not-allowed-status
method-not-allowed?
(method-not-allowed? d)
Determines if HTTP response document d has METHOD NOT ALLOWED status.
misdirected-request
(misdirected-request b)
(misdirected-request h b)
Generate HTTP response document with status MISDIRECTED REQUEST.
misdirected-request-status
misdirected-request?
(misdirected-request? d)
Determines if HTTP response document d has MISDIRECTED REQUEST status.
moved-permanently
(moved-permanently b)
(moved-permanently h b)
Generate HTTP response document with status MOVED PERMANENTLY.
moved-permanently?
(moved-permanently? d)
Determines if HTTP response document d has MOVED PERMANENTLY status.
multi-status
(multi-status b)
(multi-status h b)
Generate HTTP response document with status MULTI-STATUS.
multi-status?
(multi-status? d)
Determines if HTTP response document d has MULTI-STATUS status.
multiple-choices
(multiple-choices b)
(multiple-choices h b)
Generate HTTP response document with status MULTIPLE CHOICES.
multiple-choices?
(multiple-choices? d)
Determines if HTTP response document d has MULTIPLE CHOICES status.
network-authentication-required
(network-authentication-required b)
(network-authentication-required h b)
Generate HTTP response document with status NETWORK AUTHENTICATION REQUIRED.
network-authentication-required-status
network-authentication-required?
(network-authentication-required? d)
Determines if HTTP response document d has NETWORK AUTHENTICATION REQUIRED status.
network-connect-timeout-error-status
no-clojure-or-java-traces
(no-clojure-or-java-traces x)
no-content
(no-content b)
(no-content h b)
Generate HTTP response document with status NO CONTENT.
no-content?
(no-content? d)
Determines if HTTP response document d has NO CONTENT status.
not-acceptable
(not-acceptable b)
(not-acceptable h b)
Generate HTTP response document with status NOT ACCEPTABLE.
not-acceptable?
(not-acceptable? d)
Determines if HTTP response document d has NOT ACCEPTABLE status.
not-extended
(not-extended b)
(not-extended h b)
Generate HTTP response document with status NOT EXTENDED.
not-extended?
(not-extended? d)
Determines if HTTP response document d has NOT EXTENDED status.
not-found
(not-found b)
(not-found h b)
Generate HTTP response document with status NOT FOUND.
not-found?
(not-found? d)
Determines if HTTP response document d has NOT FOUND status.
not-implemented
(not-implemented b)
(not-implemented h b)
Generate HTTP response document with status NOT IMPLEMENTED.
not-implemented?
(not-implemented? d)
Determines if HTTP response document d has NOT IMPLEMENTED status.
not-modified
(not-modified b)
(not-modified h b)
Generate HTTP response document with status NOT MODIFIED.
not-modified?
(not-modified? d)
Determines if HTTP response document d has NOT MODIFIED status.
not-ok?
(not-ok? d)
Determine if HTTP response document d is not OK status.
ok
(ok b)
(ok h b)
Generate HTTP response document with status OK.
ok?
(ok? d)
Determines if HTTP response document d has OK status.
parse-query-string
(parse-query-string s)
Parse an HTTP query string.
parse-to-request
(parse-to-request l & {:keys [local?]})
Parse an HTTP-style endpoint to extract protocol, call, query string, and query parameters.
partial-content
(partial-content b)
(partial-content h b)
Generate HTTP response document with status PARTIAL CONTENT.
partial-content?
(partial-content? d)
Determines if HTTP response document d has PARTIAL CONTENT status.
payload-too-large
(payload-too-large b)
(payload-too-large h b)
Generate HTTP response document with status PAYLOAD TOO LARGE.
payload-too-large?
(payload-too-large? d)
Determines if HTTP response document d has PAYLOAD TOO LARGE status.
payment-required
(payment-required b)
(payment-required h b)
Generate HTTP response document with status PAYMENT REQUIRED.
payment-required?
(payment-required? d)
Determines if HTTP response document d has PAYMENT REQUIRED status.
permanent-redirect
(permanent-redirect b)
(permanent-redirect h b)
Generate HTTP response document with status PERMANENT REDIRECT.
permanent-redirect-status
permanent-redirect?
(permanent-redirect? d)
Determines if HTTP response document d has PERMANENT REDIRECT status.
pprint-string
(pprint-string x)
Returns a pretty printed (pprint) string of x.
precondition-failed
(precondition-failed b)
(precondition-failed h b)
Generate HTTP response document with status PRECONDITION FAILED.
precondition-failed-status
precondition-failed?
(precondition-failed? d)
Determines if HTTP response document d has PRECONDITION FAILED status.
precondition-required
(precondition-required b)
(precondition-required h b)
Generate HTTP response document with status PRECONDITION REQUIRED.
precondition-required-status
precondition-required?
(precondition-required? d)
Determines if HTTP response document d has PRECONDITION REQUIRED status.
processing
(processing b)
(processing h b)
Generate HTTP response document with status PROCESSING.
processing?
(processing? d)
Determines if HTTP response document d has PROCESSING status.
proxy-authentication-required
(proxy-authentication-required b)
(proxy-authentication-required h b)
Generate HTTP response document with status PROXY AUTHENTICATION REQUIRED.
proxy-authentication-required-status
proxy-authentication-required?
(proxy-authentication-required? d)
Determines if HTTP response document d has PROXY AUTHENTICATION REQUIRED status.
range-not-satisfiable
(range-not-satisfiable b)
(range-not-satisfiable h b)
Generate HTTP response document with status RANGE NOT SATISFIABLE.
range-not-satisfiable?
(range-not-satisfiable? d)
Determines if HTTP response document d has RANGE NOT SATISFIABLE status.
reference-sample-ring-request
request
(request b)
(request h b)
Generates HTTP request document.
request-timeout
(request-timeout b)
(request-timeout h b)
Generate HTTP response document with status REQUEST TIMEOUT.
request-timeout?
(request-timeout? d)
Determines if HTTP response document d has REQUEST TIMEOUT status.
request-uri-too-long-status
requested-range-not-satisfiable-status
reset-content
(reset-content b)
(reset-content h b)
Generate HTTP response document with status RESET CONTENT.
reset-content?
(reset-content? d)
Determines if HTTP response document d has RESET CONTENT status.
response
(response b)
(response s b)
(response s h b)
Generate HTTP response document.
ring-req-access-control-request-method
ring-req-if-modified-since
ring-req-if-unmodified-since
ring-req-proxy-authorization
s2i
(s2i s)
Converts string s to integer. Returns nil if unable to convert s to integer.
see-other
(see-other b)
(see-other h b)
Generate HTTP response document with status SEE OTHER.
see-other?
(see-other? d)
Determines if HTTP response document d has SEE OTHER status.
service-unavailable
(service-unavailable b)
(service-unavailable h b)
Generate HTTP response document with status SERVICE UNAVAILABLE.
service-unavailable-status
service-unavailable?
(service-unavailable? d)
Determines if HTTP response document d has SERVICE UNAVAILABLE status.
status-of?
(status-of? d v)
Determines if HTTP response document d
status-text
(status-text x)
Returns the status text for given HTTP status x.
success-body
(success-body d)
Extracts body from HTTP response document d iff the status is successful.
success?
(success? d)
Determine if HTTP response document d has status of OK or other success statuses (200 <= status <= 299).
switching-protocols
(switching-protocols b)
(switching-protocols h b)
Generate HTTP response document with status SWITCHING PROTOCOLS.
switching-protocols-status
switching-protocols?
(switching-protocols? d)
Determines if HTTP response document d has SWITCHING PROTOCOLS status.
temporary-redirect
(temporary-redirect b)
(temporary-redirect h b)
Generate HTTP response document with status TEMPORARY REDIRECT.
temporary-redirect-status
temporary-redirect?
(temporary-redirect? d)
Determines if HTTP response document d has TEMPORARY REDIRECT status.
too-many-requests
(too-many-requests b)
(too-many-requests h b)
Generate HTTP response document with status TOO MANY REQUEST.
too-many-requests?
(too-many-requests? d)
Determines if HTTP response document d has TOO MANY REQUESTS status.
trace-dup?
(trace-dup? t1 t2)
transit-content?
(transit-content? req)
Determines if content type of HTTP request req is Transit.
unauthorized
(unauthorized b)
(unauthorized h b)
Generate HTTP response document with status UNAUTHORIZED.
unauthorized?
(unauthorized? d)
Determines if HTTP response document d has UNAUTHORIZED status.
unavailable-for-legal-reasons
(unavailable-for-legal-reasons b)
(unavailable-for-legal-reasons h b)
Generate HTTP response document with status UNAVAILABLE FOR LEGAL REASONS.
unavailable-for-legal-reasons-status
unavailable-for-legal-reasons?
(unavailable-for-legal-reasons? d)
Determines if HTTP response document d has UNAVAILABLE FOR LEGAL REASONS status.
unprocessable-entity
(unprocessable-entity b)
(unprocessable-entity h b)
Generate HTTP response document with status UNPROCESSABLE ENTITY.
unprocessable-entity-status
unprocessable-entity?
(unprocessable-entity? d)
Determines if HTTP response document d has UNPROCESSABLE ENTITY status.
unwrap
(unwrap x)
Unwraps the body of x recursively.
upgrade-required
(upgrade-required b)
(upgrade-required h b)
Generate HTTP response document with status UPGRADE REQUIRED.
upgrade-required?
(upgrade-required? d)
Determines if HTTP response document d has UPGRADE REQUIRED status.
uri-too-long
(uri-too-long b)
(uri-too-long h b)
Generate HTTP response document with status URI TOO LONG.
uri-too-long?
(uri-too-long? d)
Determines if HTTP response document d has URI TOO LONG status.
use-proxy
(use-proxy b)
(use-proxy h b)
Generate HTTP response document with status USE PROXY.
use-proxy?
(use-proxy? d)
Determines if HTTP response document d has USE PROXY status.
user-agent
(user-agent x & [hm])
valid?
(valid? s)
Determine if status s is valid status code.
variant-also-negotiates
(variant-also-negotiates b)
(variant-also-negotiates h b)
Generate HTTP response document with status VARIANT ALSO NEGOTIATES.
variant-also-negotiates-status
variant-also-negotiates?
(variant-also-negotiates? d)
Determines if HTTP response document d has VARIANT ALSO NEGOTIATES status.
when-let-not-ok
macro
added in 1.6
(when-let-not-ok bindings & body)
bindings => binding-form test
When test not ok, evaluates body with binding-form bound to the
value of test
when-let-ok
macro
added in 1.6
(when-let-ok bindings & body)
bindings => binding-form test
When test ok, evaluates body with binding-form bound to the
value of test
xml-content?
(xml-content? req)
Determines if content type of HTTP request req is XML.
yaml-content?
(yaml-content? req)
Determines if content type of HTTP request req is YAML.