endpoints

package
v0.0.0-...-bcf1048 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2020 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgumentDeleter

type ArgumentDeleter interface {
	// Delete deletes an argument (and all its versions) from the site.
	// If the argument didn't exist, the error will be a NotFoundError.
	Delete(ctx context.Context, id int64) error
}

ArgumentDeleter can delete arguments by ID.

type ArgumentGetterByVersion

type ArgumentGetterByVersion interface {
	// FetchVersion should return a particular version of an argument.
	// If the the argument didn't exist, the error should be an arguments.NotFoundError.
	FetchVersion(ctx context.Context, id int64, version int) (arguments.Argument, error)
}

ArgumentGetterByVersion returns a specific version of an argument.

type ArgumentGetterLiveVersion

type ArgumentGetterLiveVersion interface {
	// FetchLive should return the latest "active" version of an argument.
	// If no argument with this ID exists, the error should be an arguments.NotFoundError.
	FetchLive(ctx context.Context, id int64) (arguments.Argument, error)
}

ArgumentGetterLiveVersion can fetch the live version of an argument.

type ArgumentSaver

type ArgumentSaver interface {
	// Save stores an argument and returns that argument's ID.
	// The ID on the input argument will be ignored.
	Save(ctx context.Context, argument arguments.Argument) (id int64, err error)
}

ArgumentSaver can save arguments.

type ArgumentUpdater

type ArgumentUpdater interface {
	// Update makes a new version of the argument. It returns the new argument's version.
	// If no argument with this ID exists, the returned error is an arguments.NotFoundError.
	Update(ctx context.Context, argument arguments.Argument) (version int, err error)
}

ArgumentUpdater can update existing arguments.

type ArgumentsGetter

type ArgumentsGetter interface {
	// FetchSome finds the arguments which match the options.
	// If none exist, error will be nil and the slice empty.
	FetchSome(ctx context.Context, options arguments.FetchSomeOptions) ([]arguments.Argument, error)
}

ArgumentsGetter can fetch lists of arguments at once.

type GetAllResponse

type GetAllResponse struct {
	Arguments []arguments.Argument `json:"arguments"`
}

GetAllResponse is the contract class for the GET /arguments?conclusion=foo endpoint

type GetOneResponse

type GetOneResponse struct {
	Argument arguments.Argument `json:"argument"`
}

GetOneResponse is the contract class for JSON responses of a single argument.

Examples include:

GET /argument/{id}
GET /argument/{id}/version/{version}
POST /arguments
PATCH /argument?id=1

etc.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server runs the service. Use NewServer() to construct one from an app config, and Start() to make it start listening and serving requests.

func NewServer

func NewServer(store Store) *Server

NewServer makes a server which defines REST endpoints for the service.

func (*Server) Handle

func (s *Server) Handle(w http.ResponseWriter, req *http.Request)

Handle exists to make testing easier. It lets the Server act without having to bind to a port.

func (*Server) Start

func (s *Server) Start(cfg config.Server, done chan<- struct{}) error

Start connects the API server to its port and blocks until it hears a shutdown signal. Once the server has shut down completely, it adds an element to the done channel.

type Store

Store has all the functions needed by the server for persistent storage

Jump to

Keyboard shortcuts

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