sigildocs

(sigil http)

(sigil http) - HTTP Client and Server Library

High-level API for HTTP/1.1 client and server functionality. Supports both HTTP and HTTPS (via lazy-loaded sigil-tls).

Quick Start

(import (sigil http))

;; Simple GET request
(http-get "https://example.com/")

;; GET with JSON response parsing (requires sigil-json)
(http-get/json "https://api.example.com/users")
; => #{ users: #[...] }

;; POST with JSON body and response
(http-post/json "https://api.example.com/users"
                #{ name: "Alice" email: "alice@example.com" })

;; Simple server
(http-serve (lambda (req)
              (http-response/html 200 "<h1>Hello!</h1>"))
            port: 8080)

Client Functions

HTTP method conveniences: http-get, http-post, http-put, http-delete, http-head, http-options, http-patch.

JSON conveniences (require sigil-json): http-get/json, http-post/json, http-response-json.

Response Constructors

Use / variants for common response types:

  • http-response/text - Plain text with charset
  • http-response/html - HTML content
  • http-response/json - JSON content
  • http-response/redirect - HTTP redirect
  • http-response/error - Error page with status
  • http-response/sse - Server-Sent Events stream

URL Handling

Functions for URL encoding, decoding, and parsing:

  • parse-url - Parse URL string into struct (scheme, host, port, path, query)
  • url-decode - Decode percent-encoded strings (%20 → space, + → space)
  • url-encode-value - Percent-encode a string for URL query values
  • build-query-string - Build ?key=val&key2=val2 from an alist
;; Parse a URL into components
(define u (parse-url "https://example.com:8080/path?q=hello%20world"))
(url-scheme u)  ; => "https"
(url-host u)    ; => "example.com"
(url-port u)    ; => 8080
(url-path u)    ; => "/path"
(url-query u)   ; => "q=hello%20world"

;; Decode percent-encoded strings
(url-decode "hello%20world")  ; => "hello world"
(url-decode "name=foo+bar")   ; => "name=foo bar"

;; Encode values for URLs
(url-encode-value "hello world")  ; => "hello+world"
(build-query-string '(("q" . "hello world") ("page" . "1")))
; => "?q=hello+world&page=1"

Sub-modules

For lower-level access, import sub-modules directly:

  • (sigil http request) - Request parsing and form data
  • (sigil http response) - Response types and serialization
  • (sigil http server) - Server implementation
  • (sigil http client) - Client implementation
  • (sigil http mime) - MIME type detection

Exports

http-requestvariable

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

ensure-listvariable

(No description)

url-decodevariable

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

HTTP-OKvariable

(No description)

HTTP-CREATEDvariable

(No description)

(No description)

(No description)

(No description)

HTTP-FOUNDvariable

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

HTTP-GONEvariable

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

sse-eventvariable

(No description)

sse-datavariable

(No description)

(No description)

http-server?variable

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

http-servevariable

(No description)

(No description)

(No description)

(No description)

parse-urlvariable

(No description)

url-schemevariable

(No description)

url-hostvariable

(No description)

url-portvariable

(No description)

url-pathvariable

(No description)

url-queryvariable

(No description)

http-getvariable

(No description)

http-postvariable

(No description)

http-putvariable

(No description)

http-deletevariable

(No description)

http-headvariable

(No description)

http-optionsvariable

(No description)

http-patchvariable

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)