test

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const SpecFile string = `` /* 1742-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 {
	PostPetsHandler  PostPetsHandlerFunc
	PostShopsHandler PostShopsHandlerFunc

	// 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)

func (API) TestClient added in v0.1.28

func (a API) TestClient() *Client

type Client

type Client struct {
	BaseURL    string
	HTTPClient HTTPClient
}

func NewClient

func NewClient(baseURL string, httpClient HTTPClient) *Client

func (*Client) PostPets

func (c *Client) PostPets(ctx context.Context, request PostPetsParams) (PostPetsResponse, error)

PostPets POST /pets

func (*Client) PostShops

func (c *Client) PostShops(ctx context.Context, request PostShopsParams) (PostShopsResponse, error)

PostShops POST /shops

type CreatePetJSON

type CreatePetJSON struct {
	Name string `json:"name"`
}

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 Error

type Error struct {
	Detail string `json:"detail"`
}

type ErrorCode

type ErrorCode int

ErrorCode - Error code

func (*ErrorCode) Parse

func (c *ErrorCode) Parse(s string) error

func (ErrorCode) String

func (h ErrorCode) String() string

type ErrorResponseResponse

type ErrorResponseResponse struct {
	Body    Error
	Headers struct {
		XErrorCode Maybe[int]
	}
}

ErrorResponseResponse - Error response

func NewErrorResponseResponse

func NewErrorResponseResponse(body Error, xErrorCode Maybe[int]) ErrorResponseResponse

func (ErrorResponseResponse) Write

func (r ErrorResponseResponse) Write(w http.ResponseWriter, code int)

type HTTPClient

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

type HTTPClientFunc

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

func (HTTPClientFunc) Do

type Maybe

type Maybe[T any] struct {
	IsSet bool
	Value T
}

func Just

func Just[T any](v T) Maybe[T]

func Nothing added in v0.1.27

func Nothing[T any]() Maybe[T]

func (Maybe[T]) Get added in v0.1.27

func (m Maybe[T]) Get() (zero T, _ bool)

func (*Maybe[T]) Set

func (m *Maybe[T]) Set(v T)

type Nullable added in v0.1.25

type Nullable[T any] struct {
	IsSet bool
	Value T
}

func Null added in v0.1.27

func Null[T any]() Nullable[T]

func Pointer added in v0.1.27

func Pointer[T any](v T) Nullable[T]

func (Nullable[T]) Get added in v0.1.27

func (m Nullable[T]) Get() (zero T, _ bool)

func (Nullable[T]) MarshalJSON added in v0.1.28

func (m Nullable[T]) MarshalJSON() ([]byte, error)

func (*Nullable[T]) Set added in v0.1.25

func (m *Nullable[T]) Set(v T)

func (*Nullable[T]) UnmarshalJSON added in v0.1.28

func (m *Nullable[T]) UnmarshalJSON(bs []byte) error

type Pet

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

type Pets

type Pets []Pet

type PostPetsHandlerFunc

type PostPetsHandlerFunc func(ctx context.Context, r PostPetsRequest) PostPetsResponse

func (PostPetsHandlerFunc) ServeHTTP

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

type PostPetsParams

type PostPetsParams struct {
	Body CreatePetJSON
}

func (PostPetsParams) HTTP

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

func (PostPetsParams) Parse

func (r PostPetsParams) Parse() (PostPetsParams, error)

type PostPetsRequest

type PostPetsRequest interface {
	HTTP() *http.Request
	Parse() (PostPetsParams, error)
}

func PostPetsHTTPRequest

func PostPetsHTTPRequest(r *http.Request) PostPetsRequest

type PostPetsResponse

type PostPetsResponse interface {
	// contains filtered or unexported methods
}

func NewPostPetsResponse200JSON

func NewPostPetsResponse200JSON(body Pets) PostPetsResponse

type PostPetsResponse200JSON

type PostPetsResponse200JSON struct {
	Body Pets
}

PostPetsResponse200JSON - Pets response

func (PostPetsResponse200JSON) Write

type PostShopsHandlerFunc

type PostShopsHandlerFunc func(ctx context.Context, r PostShopsRequest) PostShopsResponse

func (PostShopsHandlerFunc) ServeHTTP

type PostShopsParams

type PostShopsParams struct {
	Body CreatePetJSON
}

func (PostShopsParams) HTTP

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

func (PostShopsParams) Parse

func (r PostShopsParams) Parse() (PostShopsParams, error)

type PostShopsRequest

type PostShopsRequest interface {
	HTTP() *http.Request
	Parse() (PostShopsParams, error)
}

func PostShopsHTTPRequest

func PostShopsHTTPRequest(r *http.Request) PostShopsRequest

type PostShopsResponse

type PostShopsResponse interface {
	// contains filtered or unexported methods
}

func NewPostShopsResponse200JSON

func NewPostShopsResponse200JSON(body Pets) PostShopsResponse

type PostShopsResponse200JSON

type PostShopsResponse200JSON struct {
	Body Pets
}

PostShopsResponse200JSON - Pets response

func (PostShopsResponse200JSON) Write

Jump to

Keyboard shortcuts

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