Categorygithub.com/ExploratoryEngineering/rest
modulepackage
1.0.1
Repository: https://github.com/exploratoryengineering/rest.git
Documentation: pkg.go.dev

# README

REST utilities

GoDoc Build Status Go Report Card codecov

This is a (for now) small package with a few handy utilities when creating HTTP-based APIs:

  • A simple router to handle parameters in routes
  • A CORS filter

# Functions

AddCORSHeaders adds CORS headers to the response.
BasicAuthWrapper wraps all requests with WWW-Authenticate headers and validates against the credential store.
DefaultKeepAliveMessage is the default KeepAlive-message.
GetPathKey is a simple utility function that will return the (string) value for the specified key in the path.
NewMemoryCredentialStore creates a new MemoryCredentialStore instance with a single entry.
NewParameterRouter creates a new router instance.
WebsocketHandler generates a http.HandlerFunc from the websocket adapter.

# Structs

MemoryCredentialStore is a memory-backed credential store.
ParameterRouter implements a request URI router that allows for path parameters in URIs, ie requests like https://example.com/api/thing/0424242/subthing/ - ie presenting resources with IDs in the request URI rather than having to rely on query parameters.

# Interfaces

CredentialStore is a simple credential store.
WebsocketStreamer is an adapter type for websocket streams.

# Type aliases

PathParameter is the type used when storing parameters in the context.