Package documentation

whiplash

1.0.0

The Whiplash cat, in goggles and a purple scarf

whiplash

Package Version Hex Docs Tests

An HTTP/1.1, HTTP/2, HTTP/3 and WebSocket server for Pooka, on Pooka OTP.

Installation

sh
pooka add whiplash
pooka add pooka_http
pooka add pooka_otp

Example

Pooka
module main

import pooka/http
import pooka/otp
import whiplash

handle(request: http.Request) -> http.Response {
  match request.segments() {
    [] -> http.text(200, "Hello, Joe!")
    _ -> http.text(404, "Not found")
  }
}

main() {
  let assert Ok(_) = whiplash.start(whiplash.options(8080), handle)
  otp.sleep_forever()
}

One port speaks HTTP/1.1 and HTTP/2. With a certificate, whiplash.start_tls adds TLS and HTTP/3 on the same port number. Streaming, server-sent events, files, uploads and WebSockets work on every protocol, and the protocol modules (HTTP/1, HPACK, HTTP/2, QUIC, QPACK, HTTP/3, WebSocket) are sans-IO and usable on their own.

See the guides and API documentation for the rest.

Licence

Licensed under the Apache License, Version 2.0.