flix

0.70.0

Net.Https

eff HttpsSource

The effect used to send HTTPS-only requests.

Operations

def request(req: HttpRequest): Result[IoError, HttpResponse] \ Https Source

Definitions

def delete(url: String): Result[IoError, HttpResponse] \ Https Source

Sends a DELETE request to the given url.

def get(url: String): Result[IoError, HttpResponse] \ Https Source

Sends a GET request to the given url.

def handle(f: a -> b \ ef): a -> b \ (ef - Https) + IO Source

Handles the Https effect of the given function f.

Re-interprets the Https effect using the IO effect. Validates that request URLs use the https:// scheme.

def head(url: String): Result[IoError, HttpResponse] \ Https Source

Sends a HEAD request to the given url.

def options(url: String): Result[IoError, HttpResponse] \ Https Source

Sends an OPTIONS request to the given url.

def patch(url: String, body: String): Result[IoError, HttpResponse] \ Https Source

Sends a PATCH request to the given url with the given body.

def post(url: String, body: String): Result[IoError, HttpResponse] \ Https Source

Sends a POST request to the given url with the given body.

def put(url: String, body: String): Result[IoError, HttpResponse] \ Https Source

Sends a PUT request to the given url with the given body.

@DefaultHandler
def runWithIO(f: Unit -> a \ ef): a \ (ef - Https) + IO Source

Runs the Https effect of the given function f.

Re-interprets the Https effect using the IO effect.

def send(req: HttpRequest): Result[IoError, HttpResponse] \ Https Source

Sends the given request req via the Https effect.

def withBaseUrl(base: String, f: Unit -> a \ ef): a \ (ef - Https) + Https Source

Middleware that intercepts the Https effect, prepending base to request URLs that do not already start with a scheme. Absolute URLs (where "://" appears before the first "/") are left unchanged.

def withCircuitBreaker(ft: { failureThreshold = Int32 }, cdm: { cooldown = Duration }, f: Unit -> a \ ef): a \ (ef - Https) + Clock + Https Source

Middleware that intercepts the Https effect, implementing a circuit breaker.

Tracks consecutive failures (transport errors and 5xx server errors). After failureThreshold consecutive failures, the circuit opens and immediately rejects requests for cooldown. After the cooldown, one probe request is allowed through (half-open state). A successful probe closes the circuit; a failed probe restarts the cooldown.

Non-failure responses (2xx, 3xx, 4xx) reset the failure counter.

def withDefaultHeaders(defaults: Map[String, List[String]], f: Unit -> a \ ef): a \ (ef - Https) + Https Source

Middleware that intercepts the Https effect, injecting default headers into every request. Headers already present on the request are not overridden.

def withLogging(f: Unit -> a \ ef): a \ (ef - Https) + Https + Logger Source

Middleware that intercepts the Https effect, logging each request and its corresponding response via the Logger effect at Debug level.

def withMinInterval(ims: { interval = Duration }, f: Unit -> a \ ef): a \ (ef - Https) + Clock + Https Source

Middleware that intercepts the Https effect, enforcing a minimum interval between consecutive HTTPS requests.

def withRetry(strategy: Int32 -> (HttpRequest -> (RetryOutcome -> RetryDecision \ ef1)), f: Unit -> a \ ef2): a \ ef1 + (ef2 - Https) + Https Source

Middleware that intercepts the Https effect, adding retry logic.

The strategy function decides whether to retry and how long to wait. Validates the https:// scheme once before entering the retry loop. Each Https.request is re-raised to an outer Https handler that performs the actual I/O.

def withSlidingWindow(mr: { maxRequests = Int32 }, wms: { window = Duration }, f: Unit -> a \ ef): a \ (ef - Https) + Clock + Https Source

Middleware that intercepts the Https effect, enforcing a sliding-window rate limit. Allows at most maxRequests within any rolling window. When the limit is reached, sleeps until the oldest request expires.

def withTokenBucket(bs: { burstSize = Int32 }, ims: { interval = Duration }, f: Unit -> a \ ef): a \ (ef - Https) + Clock + Https Source

Middleware that intercepts the Https effect, enforcing a token-bucket rate limit. Allows an initial burst of burstSize requests, then sustains at 1 request per interval.