receiver

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package receiver is scaffolding around net/http that facilitates a RESTful HTTP API with certain patterns implicitly enforced:

- When working on the same urls, all Methods should use the exact same data structures. E.g.: What you PUT is the same as what you GET out again. No cheating.

- ETag is computed for all responses.

- All responses are JSON-encoded, including error messages.

See objects/thing.go for how to use this, but the essence is:

1. Make whatever data structure you need. 2. Implement one or more of gondulapi.Getter/Putter/Poster/Deleter. 3. Use AddHandler() to register that data structure on a URL path 4. Grab lunch.

Receiver tries to do all HTTP and caching-related tasks for you, so you don't have to.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHandler

func AddHandler(url string, a Allocator)

AddHandler registeres an allocator/data structure with a url. The allocator should be a function returning an empty datastrcuture which implements one or more of gondulapi.Getter, Putter, Poster and Deleter

func Start

func Start()

Start a net/http server and handle all requests registered. Never returns.

Types

type Allocator

type Allocator func() interface{}

Allocator is used to allocate a data structure that implements at least one of Getter, Putter, Poster or Deleter from gondulapi.

Jump to

Keyboard shortcuts

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