(address-string-for request-map)
Converts a request map into a URL string. Handles both keyword (:http) and string ('http') schemes. Returns a string in the format: scheme://server-name:port/uri?query-string where each component is optional.
Converts a request map into a URL string. Handles both keyword (:http) and string ('http') schemes. Returns a string in the format: scheme://server-name:port/uri?query-string where each component is optional.
(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 either http-kit (:method) or clj-http (:request-method) style requests
Gets the request method from either http-kit (:method) or clj-http (:request-method) style requests
(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.
(normalize-query-params params)
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.
(normalize-request request)
Normalizes a request map to a consistent format.
Normalizes a request map to a consistent format. - Converts string URLs to request maps - Sets default method to :get - Handles HttpEntity bodies - Ensures consistent method key (:method or :request-method)
(normalize-url-for-matching url)
Normalizes a URL string by removing trailing slashes for consistent matching
Normalizes a URL string by removing trailing slashes for consistent matching
(parse-query-string query-string)
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-alternatives-to request uris-fn)
Given a request map and a function to generate potential URIs, returns a sequence of all possible alternative request maps by combining different schemes, server ports, URIs, and query strings. Each alternative preserves all other fields from the original request.
The uris-fn parameter should be a function that takes a request map and returns a sequence of potential URIs for that request.
Given a request map and a function to generate potential URIs, returns a sequence of all possible alternative request maps by combining different schemes, server ports, URIs, and query strings. Each alternative preserves all other fields from the original request. The uris-fn parameter should be a function that takes a request map and returns a sequence of potential URIs for that request.
(potential-query-strings-for request-map)
Given a request map, returns a vector of potential query strings. If the request has no query string or an empty one, returns ['', nil]. If it has a query string, returns all possible permutations of its parameters.
Given a request map, returns a vector of potential query strings. If the request has no query string or an empty one, returns ['', nil]. If it has a query string, returns all possible permutations of its parameters.
(potential-schemes-for request-map)
Given a request map, returns a vector of potential schemes. Handles both string ('http') and keyword (:http) schemes. If the request's scheme is http/nil, returns [http nil], otherwise returns a vector with just the specified scheme.
Given a request map, returns a vector of potential schemes. Handles both string ('http') and keyword (:http) schemes. If the request's scheme is http/nil, returns [http nil], otherwise returns a vector with just the specified scheme.
(potential-server-ports-for request-map)
Given a request map, returns a vector of potential server ports. If the request's server-port is 80 or nil, returns [80 nil], otherwise returns a vector with just the specified port.
Given a request map, returns a vector of potential server ports. If the request's server-port is 80 or nil, returns [80 nil], otherwise returns a vector with just the specified port.
(query-params-match? expected-query-params request)
Checks if the actual query parameters in a request match the expected ones. Works with both query-string and query-params formats, and handles both httpkit and clj-http parameter styles.
Checks if the actual query parameters in a request match the expected ones. Works with both query-string and query-params formats, and handles both httpkit and clj-http parameter styles.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close