Liking cljdoc? Tell your friends :D

httpkit.stub


*call-counts*clj

source

*expected-counts*clj

source

*in-isolation*clj

source

*stub-routes*clj

source

address-string-forclj

(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.
sourceraw docstring

create-detailed-error-messageclj

(create-detailed-error-message request routes)

Creates a detailed error message for route matching failures.

Creates a detailed error message for route matching failures.
sourceraw docstring

create-responseclj

(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.
sourceraw docstring

defaults-or-valueclj

(defaults-or-value defaults value)

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
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
sourceraw docstring

execute-with-validationclj

(execute-with-validation f)

Common execution logic for both stub-bindings and global-http-stub. Sets up the necessary state, executes the function, validates call counts, and handles exceptions consistently.

Common execution logic for both stub-bindings and global-http-stub.
Sets up the necessary state, executes the function, validates call counts,
and handles exceptions consistently.
sourceraw docstring

format-available-routesclj

(format-available-routes routes)

Formats the available routes in a human-readable way for error messages.

Formats the available routes in a human-readable way for error messages.
sourceraw docstring

get-request-methodclj

(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
sourceraw docstring

get-request-query-paramsclj

(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.
sourceraw docstring

methods-match?clj

(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.
sourceraw docstring

normalize-pathclj

(normalize-path path)

Normalizes a URL path by ensuring it has a trailing slash if not empty.

Normalizes a URL path by ensuring it has a trailing slash if not empty.
sourceraw docstring

normalize-query-paramsclj

(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.
sourceraw docstring

normalize-requestclj

(normalize-request request)
source

normalize-urlclj

(normalize-url url & [options])

Comprehensive URL normalization function that handles various aspects of URL normalization. Options is a map that can include:

  • :remove-trailing-slash - removes trailing slashes (default: false)
  • :normalize-path - ensures path has a trailing slash (default: true)
  • :lowercase - converts the URL to lowercase (default: false)
Comprehensive URL normalization function that handles various aspects of URL normalization.
Options is a map that can include:
- :remove-trailing-slash - removes trailing slashes (default: false)
- :normalize-path - ensures path has a trailing slash (default: true)
- :lowercase - converts the URL to lowercase (default: false)
sourceraw docstring

normalize-url-for-matchingclj

(normalize-url-for-matching url)

Normalizes a URL string by removing trailing slashes for consistent matching. This is a specialized version of normalize-url with specific options.

Normalizes a URL string by removing trailing slashes for consistent matching.
This is a specialized version of normalize-url with specific options.
sourceraw docstring

parse-query-stringclj

(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.
sourceraw docstring

parse-urlclj

(parse-url url)

Parse a URL string into a map containing :scheme, :server-name, :server-port, :uri, and :query-string. Uses the normalize-path function to ensure consistent URI formatting.

Parse a URL string into a map containing :scheme, :server-name, :server-port, :uri, and :query-string.
Uses the normalize-path function to ensure consistent URI formatting.
sourceraw docstring

potential-alternatives-toclj

(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.

Performance optimized to limit the number of combinations generated and to short-circuit when not needed.

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.

Performance optimized to limit the number of combinations generated and
to short-circuit when not needed.
sourceraw docstring

potential-query-strings-forclj

(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.
sourceraw docstring

potential-schemes-forclj

(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.
sourceraw docstring

potential-server-ports-forclj

(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.
sourceraw docstring

potential-uris-forclj

(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.

Returns a set of potential URIs for a request.
Uses defaults-or-value to handle common cases like '/', '', or nil.
sourceraw docstring

query-params-match?clj

(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.
sourceraw docstring

RouteMatchercljprotocol

matchesclj

(matches address method request)
source

validate-all-call-countsclj

(validate-all-call-counts)
source

with-global-http-stubcljmacro

(with-global-http-stub routes & body)
source

with-global-http-stub-baseclj

(with-global-http-stub-base routes f)
source

with-global-http-stub-in-isolationcljmacro

(with-global-http-stub-in-isolation routes & body)
source

with-http-stubcljmacro

(with-http-stub routes & body)
source

with-http-stub-in-isolationcljmacro

(with-http-stub-in-isolation routes & body)
source

with-stub-bindingsclj

(with-stub-bindings routes f)
source

wrap-request-with-stubclj

(wrap-request-with-stub client)
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close