server

package
v0.3.0-M1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2018 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrBadRouting is returned when an expected path variable is missing, which is always programmer error.
	ErrBadRouting = fmt.Errorf("inconsistent mapping between route and handler, %s", bugReportHelp)
	ErrFoundABug  = fmt.Errorf("Snuck into encodeError with err == nil, %s", bugReportHelp)

	MaxContentLength = 1 * 1024 * 1024 // bytes
)
View Source
var (
	ErrNotFound      = errors.New("Not Found")
	ErrAlreadyExists = errors.New("Already Exists")
)

Functions

func MakeCreateBatchEndpoint

func MakeCreateBatchEndpoint(s Service) endpoint.Endpoint

MakeCreateFileEndpoint returns an endpoint via the passed service.

func MakeCreateFileEndpoint

func MakeCreateFileEndpoint(s Service, r Repository) endpoint.Endpoint

MakeCreateFileEndpoint returns an endpoint via the passed service.

func MakeDeleteBatchEndpoint

func MakeDeleteBatchEndpoint(s Service) endpoint.Endpoint

func MakeDeleteFileEndpoint

func MakeDeleteFileEndpoint(s Service) endpoint.Endpoint

func MakeGetBatchEndpoint

func MakeGetBatchEndpoint(s Service) endpoint.Endpoint

func MakeGetBatchesEndpoint

func MakeGetBatchesEndpoint(s Service) endpoint.Endpoint

func MakeGetFileContentsEndpoint

func MakeGetFileContentsEndpoint(s Service) endpoint.Endpoint

func MakeGetFileEndpoint

func MakeGetFileEndpoint(s Service) endpoint.Endpoint

MakeGetFileEndpoint returns an endpoint via the passed service. Primarily useful in a server.

func MakeGetFilesEndpoint

func MakeGetFilesEndpoint(s Service) endpoint.Endpoint

func MakeHTTPHandler

func MakeHTTPHandler(s Service, repo Repository, logger log.Logger) http.Handler

func MakeValidateFileEndpoint

func MakeValidateFileEndpoint(s Service) endpoint.Endpoint

func NextID

func NextID() string

NextID generates a new resource ID. Do not assume anything about the data structure.

Multiple calls to NextID() have no concern about producing lexicographically ordered output.

Types

type Endpoints

type Endpoints struct {
	CreateFileEndpoint      endpoint.Endpoint
	GetFileEndpoint         endpoint.Endpoint
	GetFilesEndpoint        endpoint.Endpoint
	DeleteFileEndpoint      endpoint.Endpoint
	GetFileContentsEndpoint endpoint.Endpoint
	ValidateFileEndpoint    endpoint.Endpoint
	CreateBatchEndpoint     endpoint.Endpoint
	GetBatchesEndpoint      endpoint.Endpoint
	GetBatchEndpoint        endpoint.Endpoint
	DeleteBatchEndpoint     endpoint.Endpoint
}

func MakeServerEndpoints

func MakeServerEndpoints(s Service, r Repository) Endpoints

type Middleware

type Middleware func(Service) Service

Middleware describes a service (as opposed to endpoint) middleware.

func LoggingMiddleware

func LoggingMiddleware(logger log.Logger) Middleware

type Repository

type Repository interface {
	StoreFile(file *ach.File) error
	FindFile(id string) (*ach.File, error)
	FindAllFiles() []*ach.File
	DeleteFile(id string) error
	StoreBatch(fileID string, batch ach.Batcher) error
	FindBatch(fileID string, batchID string) (ach.Batcher, error)
	FindAllBatches(fileID string) []ach.Batcher
	DeleteBatch(fileID string, batchID string) error
}

Repository is the Service storage mechanism abstraction

func NewRepositoryInMemory

func NewRepositoryInMemory() Repository

NewRepositoryInMemory is an in memory ach storage repository for files

type Service

type Service interface {
	// CreateFile creates a new ach file record and returns a resource ID
	CreateFile(f *ach.FileHeader) (string, error)
	// AddFile retrieves a file based on the File id
	GetFile(id string) (*ach.File, error)
	// GetFiles retrieves all files accessible from the client.
	GetFiles() []*ach.File
	// DeleteFile takes a file resource ID and deletes it from the store
	DeleteFile(id string) error
	// GetFileContents creates a valid plaintext file in memory assuming it has a FileHeader and at least one Batch record.
	GetFileContents(id string) (io.Reader, error)
	// ValidateFile
	ValidateFile(id string) error

	// CreateBatch creates a new batch within and ach file and returns its resource ID
	CreateBatch(fileID string, bh *ach.BatchHeader) (string, error)
	// GetBatch retrieves a batch based oin the file id and batch id
	GetBatch(fileID string, batchID string) (ach.Batcher, error)
	// GetBatches retrieves all batches associated with the file id.
	GetBatches(fileID string) []ach.Batcher
	// DeleteBatch takes a fileID and BatchID and removes the batch from the file
	DeleteBatch(fileID string, batchID string) error
}

Service is a REST interface for interacting with ACH file structures TODO: Add ctx to function parameters to pass the client security token

func NewService

func NewService(r Repository) Service

NewService creates a new concrete service

Jump to

Keyboard shortcuts

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