(body-bytes obj)
If obj
is a byte-array, return it, otherwise use utf8-bytes
.
If `obj` is a byte-array, return it, otherwise use `utf8-bytes`.
(create-response response request)
Creates a response map with default values merged with the provided response. If response is a function, it will be called with the request as an argument. Returns a map with :status, :headers, and :body.
Creates a response map with default values merged with the provided response. If response is a function, it will be called with the request as an argument. Returns a map with :status, :headers, and :body.
(defaults-or-value defaults value)
Given a set of default values and a value, returns either:
Given a set of default values and a value, returns either: - a vector of all default values (reversed) if the value is in the defaults - a vector containing just the value if it's not in the defaults
(get-request-method request)
Gets the request method from the request map
Gets the request method from the request map
(get-request-query-params request)
Extracts and normalizes query parameters from a request. Handles both :query-params and :query-string formats.
Extracts and normalizes query parameters from a request. Handles both :query-params and :query-string formats.
(methods-match? expected-method request)
Checks if a request method matches an expected method. Handles :any as a wildcard method.
Checks if a request method matches an expected method. Handles :any as a wildcard method.
Normalizes query parameters to a consistent format. Handles both string and keyword keys, and converts all values to strings.
Normalizes query parameters to a consistent format. Handles both string and keyword keys, and converts all values to strings.
Normalizes a URL string by removing trailing slashes for consistent matching
Normalizes a URL string by removing trailing slashes for consistent matching
Parses a query string into a map of normalized parameters. Returns empty map for nil or empty query string.
Parses a query string into a map of normalized parameters. Returns empty map for nil or empty query string.
(parse-url url)
Parse a URL string into a map containing :scheme, :server-name, :server-port, :uri, and :query-string
Parse a URL string into a map containing :scheme, :server-name, :server-port, :uri, and :query-string
(potential-uris-for request-map)
Returns a set of potential URIs for a request. Uses defaults-or-value to handle common cases like '/', '', or nil. Also handles URIs with or without trailing slashes and normalized paths.
Returns a set of potential URIs for a request. Uses defaults-or-value to handle common cases like '/', '', or nil. Also handles URIs with or without trailing slashes and normalized paths.
(utf8-bytes s)
Returns the UTF-8 bytes corresponding to the given string.
Returns the UTF-8 bytes corresponding to the given string.
(with-global-http-stub-base routes wrap-body & body)
Base implementation of with-global-http-stub that both clj-http and httpkit extend
Base implementation of with-global-http-stub that both clj-http and httpkit extend
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close