etagjson

package
v0.2.0-rc.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package etagjson serves JSON that is encoded once and tagged with a strong ETag, so an unchanged snapshot costs neither an encode nor a body. The client revalidates itself by sending If-None-Match; the response is never stored by an HTTP cache.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(w http.ResponseWriter, r *http.Request, b Body)

Serve answers 304 when the request's If-None-Match names b, and the body otherwise. The response is no-store: the webview's HTTP cache leaks memory on WebKitGTK 2.50, so the app keeps the last answer and sends If-None-Match itself, which is what turns an unchanged snapshot into a 304.

Types

type Body

type Body struct {
	Data []byte
	ETag string
}

Body is an encoded response and its ETag, the digest of the bytes.

func Encode

func Encode(v any) (Body, error)

Encode marshals v the way json.Encoder does, with its trailing newline.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL