server

package
v0.0.0-...-72b452d Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PaymentData

type PaymentData struct {
	Attributes     storage.Payment `json:"attributes"`
	ID             uuid.UUID       `json:"id"`
	OrganisationID uuid.UUID       `json:"organisation_id"`
	Type           string          `json:"type"`
	Version        int             `json:"version"`
}

type ReadWrapper

type ReadWrapper struct {
	Data  []PaymentData    `json:"data"`
	Links ReadWrapperLinks `json:"links"`
}

ReadWrapper adds some extra information around Payment structs that are read from the API.

func NewWrapper

func NewWrapper(s string) *ReadWrapper

NewWrapper will return a new ReadWrapper.

func (*ReadWrapper) AddPayment

func (rw *ReadWrapper) AddPayment(id uuid.UUID, p storage.Payment)

AddPayment will add a Payment with some other boilerplate attributes to a ReadWrapper.

type ReadWrapperLinks struct {
	Self string `json:"self"`
}

type Server

type Server struct {
	Router  *chi.Mux
	Storage storage.PaymentStorage
}

Server is a RESTful HTTP API server offering CRUD functionality to store Payments.

func New

func New(st StorageType, logDebug bool, cs ...string) *Server

New creates a new Server utilising the given StorageType to handle Payment storage, and sets up the HTTP router. It takes an optional string argument which will set the hostname of the MongoDB server to connect to.

type StorageType

type StorageType byte

StorageType is an enum to differentiate between storage implementations.

const (
	// InMemory describes a storage system that is held in memory only, and not persisted to disk.
	InMemory StorageType = iota

	// Mongo describes a storage system that persists Payment records in a MongoDB database.
	Mongo
)

Jump to

Keyboard shortcuts

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