api

package
v0.0.0-...-1a3755f Latest Latest
Warning

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

Go to latest
Published: May 7, 2019 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

API contains all the routes for the userstorage service

func NewAPI

func NewAPI(db *gorm.DB, config *config.Config) *API

NewAPI creates a new API object according to the configuration

func (*API) ListenAndServe

func (api *API) ListenAndServe(addr string)

ListenAndServe will finally start the real http server

type APITest

type APITest struct {
	DB      *gorm.DB
	Config  *config.Config
	BaseURL string
	T       *testing.T
}

func NewAPITest

func NewAPITest(t *testing.T, baseURL string) *APITest

NewAPITest create a api test with tmp database and config

func (*APITest) Request

func (t *APITest) Request(method string, url string, data interface{}) *httptest.ResponseRecorder

Request create a request with optional body

func (*APITest) TestEndpoint

func (t *APITest) TestEndpoint(method string, url string, body io.Reader) (*httptest.ResponseRecorder, *http.Request)

TestEndpoint create a httptest recorder and a request to call a local endpoint

Jump to

Keyboard shortcuts

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