test

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const SpecFile string = `` /* 641-byte string literal not displayed */

Variables

View Source
var LogError = func(err error) {
	log.Println(fmt.Sprintf("Error: %v", err))
}

Functions

func SchemaPath

func SchemaPath(r *http.Request) (string, bool)

func SpecFileHandler

func SpecFileHandler() http.Handler

Types

type API

type API struct {
	GetPetsHandler      GetPetsHandlerFunc
	GetPetsNamesHandler GetPetsNamesHandlerFunc

	// not found
	NotFoundHandler http.Handler
	// spec file
	SpecFileHandler http.Handler

	Middlewares []func(h http.Handler) http.Handler
}

func (*API) ServeHTTP

func (rt *API) ServeHTTP(rw http.ResponseWriter, r *http.Request)

type Client added in v0.0.2

type Client struct {
	BaseURL    string
	HTTPClient HTTPClient
}

func NewClient added in v0.0.2

func NewClient(baseURL string, httpClient HTTPClient) *Client

func (*Client) GetPets added in v0.0.2

func (c *Client) GetPets(ctx context.Context, request GetPetsParams) (GetPetsResponse, error)

GetPets - GET /pets

func (*Client) GetPetsNames added in v0.0.2

func (c *Client) GetPetsNames(ctx context.Context, request GetPetsNamesParams) (GetPetsNamesResponse, error)

GetPetsNames - GET /pets/names

type ErrParseParam

type ErrParseParam struct {
	In        string
	Parameter string
	Reason    string
	Err       error
}

func (ErrParseParam) Error

func (e ErrParseParam) Error() string

func (ErrParseParam) Unwrap

func (e ErrParseParam) Unwrap() error

type GetPetsHandlerFunc

type GetPetsHandlerFunc func(ctx context.Context, r GetPetsRequest) GetPetsResponse

func (GetPetsHandlerFunc) ServeHTTP

func (f GetPetsHandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request)

type GetPetsNamesHandlerFunc

type GetPetsNamesHandlerFunc func(ctx context.Context, r GetPetsNamesRequest) GetPetsNamesResponse

func (GetPetsNamesHandlerFunc) ServeHTTP

type GetPetsNamesParams added in v0.0.3

type GetPetsNamesParams struct {
}

func (GetPetsNamesParams) HTTP added in v0.0.3

func (r GetPetsNamesParams) HTTP() *http.Request

func (GetPetsNamesParams) Parse added in v0.0.3

type GetPetsNamesRequest

type GetPetsNamesRequest interface {
	HTTP() *http.Request
	Parse() GetPetsNamesParams
}

func GetPetsNamesHTTPRequest added in v0.0.2

func GetPetsNamesHTTPRequest(r *http.Request) GetPetsNamesRequest

type GetPetsNamesResponse added in v0.0.2

type GetPetsNamesResponse interface {
	Write(w http.ResponseWriter)
	// contains filtered or unexported methods
}

func NewGetPetsNamesResponse200JSON added in v0.0.2

func NewGetPetsNamesResponse200JSON(body []string) GetPetsNamesResponse

type GetPetsNamesResponse200JSON

type GetPetsNamesResponse200JSON struct {
	Body []string
}

func (GetPetsNamesResponse200JSON) Write added in v0.0.2

type GetPetsParams added in v0.0.3

type GetPetsParams struct {
}

func (GetPetsParams) HTTP added in v0.0.3

func (r GetPetsParams) HTTP() *http.Request

func (GetPetsParams) Parse added in v0.0.3

func (r GetPetsParams) Parse() GetPetsParams

type GetPetsRequest

type GetPetsRequest interface {
	HTTP() *http.Request
	Parse() GetPetsParams
}

func GetPetsHTTPRequest added in v0.0.2

func GetPetsHTTPRequest(r *http.Request) GetPetsRequest

type GetPetsResponse added in v0.0.2

type GetPetsResponse interface {
	Write(w http.ResponseWriter)
	// contains filtered or unexported methods
}

func NewGetPetsResponse200JSON added in v0.0.2

func NewGetPetsResponse200JSON(body []Pet) GetPetsResponse

type GetPetsResponse200JSON

type GetPetsResponse200JSON struct {
	Body []Pet
}

func (GetPetsResponse200JSON) Write added in v0.0.2

type HTTPClient added in v0.0.2

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

type HTTPClientFunc added in v0.0.11

type HTTPClientFunc func(*http.Request) (*http.Response, error)

func (HTTPClientFunc) Do added in v0.0.11

type Pet

type Pet struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
	Tag  string `json:"tag"`
}

Jump to

Keyboard shortcuts

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