server

package
v0.0.0-...-a4c5897 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2021 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	Port         string
	Version      string
	Router       *httprouter.Router
	Validator    validator.Validator
	JwtSignatory *jwt.JwtSignatory
	DB           *sql.DB
}

Server is a struct responsible for managing a *httprouter.Router. All HandlerFunc Closures hang off of this struct, so all HandlerFunc's have access to the server values.

func (*Server) Start

func (s *Server) Start()

Start binds all routes to our router and then serves our router to handle all requests on incoming connections.

type TestServer

type TestServer struct {
	Server
	EphemeralDatabase *database.EphemeralDatabase
}

TestServer is a utility Server wrapper that is used to simplify writing integration tests. This really serves two purposes:

1. Plug all of the dependencies up in one place 2. Spin up an EphemeralDatabase that can be Terminated w/ a Shutdown function

func NewTestServer

func NewTestServer() (*TestServer, error)

func (*TestServer) NewAuthenticatedRequest

func (t *TestServer) NewAuthenticatedRequest(method, target, userId string, body io.Reader) *http.Request

NewAuthenticatedRequest generates a request that's authenticated as if the user with userId has actually gone through a proper authentication flow.

func (*TestServer) SeedBill

func (t *TestServer) SeedBill(userId string) map[string]interface{}

Seeds a random Bill into our TestServer's database. This returns a map[string]interface{} for ease of result comparison, as the output of a parsed HTTPRecorder's result will be untyped.

func (*TestServer) SeedPayment

func (t *TestServer) SeedPayment(billId string) map[string]interface{}

Seeds a random Payment into our TestServer's database. This returns a map[string]interface{} for ease of result comparison, as the output of a parsed HTTPRecorder's result will be untyped.

func (*TestServer) SeedUser

func (t *TestServer) SeedUser() map[string]interface{}

Seeds a random User into our TestServer's database. This returns a map[string]interface{} for ease of result comparison, as the output of a parsed HTTPRecorder's result will be untyped.

func (*TestServer) Shutdown

func (t *TestServer) Shutdown()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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