Skip to content

horvathandris/wispie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🪶 wispie

Package Version Hex Docs

A tiny Gleam library for rendering 🧚 wisp HTTP responses into readable text snapshots. Designed for use with 🐦‍⬛ birdie snapshot testing, but also handy for debugging and logging.

✨ Features

  • Converts response.Response(wisp.Body) into a nicely formatted string.
  • Includes status, headers, and body — all in one view.
  • Automatically detects and formats body content:
    • wisp.Text → pretty-printed based on content type (application/json, text/html, etc.)
    • wisp.Bytes → UTF-8 decoded when possible.
    • wisp.File → compact file reference with offset and limit.
  • Integrates seamlessly with Birdie snapshot tests.
  • Uses contenty for robust Content-Type parsing.

🧩 Installation

gleam add wispie@1

🚀 Usage

import gleam/http/response
import wisp
import wispie
import birdie

pub fn json_response_snapshot__test() {
  let response_body =
    "
    {
      \"id\": \"123\",
      \"name\": \"John Doe\"
    }
    "

  let response = wisp.json_response(response_body, 201)

  response
  |> wispie.response_to_string
  |> birdie.snap("json_response")
}

produces a clean snapshot like

201
content-type: application/json

{
  "id": "123",
  "name": "John Doe"
}

Further documentation can be found at https://hexdocs.pm/wispie.

🧑‍💻 Development

gleam test  # Run the tests

🧰 Related

About

Render wisp HTTP responses into a human-readable representation

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages