api

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 17 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// QueryParameterCount represents the query parameter
	// for the approximate number of items to retrieve.
	QueryParameterCount = "count"
	// QueryParameterCursor represents the query parameter
	// for the cursor used in pagination.
	QueryParameterCursor = "cursor"
	// QueryParameterTo represents the query parameter
	// for the redirect destination
	QueryParameterTo = "to"
)

Variables

View Source
var (
	ErrNegativeCount           = errors.New("the count must be a positive integer")
	ErrInternal                = errors.New("internal error")
	ErrInvalidTo               = errors.New("the 'to' query parameter must be a valid relative path")
	ErrToNotAllowed            = errors.New("the 'to' query parameter is not yet implemented")
	ErrInvalidCount            = errors.New("the count must be an integer giving the requested number of redirects")
	ErrInvalidOrNegativeCursor = errors.New("the redirects cursor was invalid. It must be a positive integer")
	ErrInvalidBase64Id         = errors.New("the base64 id provided is invalid")
	ErrNotFound                = errors.New("not found")
	ErrInvalidRequestBody      = errors.New("the request body provided is invalid")
	ErrIDFromMismatch          = errors.New("the 'from' field does not match the base64 id")
	ErrFromToNotRelative       = errors.New("'from' and 'to' must be relative paths starting with '/'")
	ErrCircularPaths           = errors.New("'from' and 'to' cannot be the same")
)

A list of error messages for Redirect API

Functions

This section is empty.

Types

type RedirectAPI added in v0.3.0

type RedirectAPI struct {
	Router        *mux.Router
	RedirectStore *store.Datastore
	// contains filtered or unexported fields
}

RedirectAPI provides a struct to wrap the api around

func Setup

func Setup(ctx context.Context, r *mux.Router, dataStore *store.Datastore, auth authorisation.Middleware, cfg *config.Config) *RedirectAPI

Setup function sets up the api and returns an api

func (*RedirectAPI) DeleteRedirect added in v0.3.3

func (api *RedirectAPI) DeleteRedirect(w http.ResponseWriter, r *http.Request)

DeleteRedirect handles the deletion of a redirect

func (*RedirectAPI) UpsertRedirect added in v0.3.2

func (api *RedirectAPI) UpsertRedirect(w http.ResponseWriter, r *http.Request)

UpsertRedirect handles the creation or update of redirects

Jump to

Keyboard shortcuts

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