test

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const SpecFile string = `servers:
# - url: "https://demo.example.com:8443/api/v1"
- url: https://{username}.example.com:{port}/{basePath}
  description: The production API server
  variables:
    username:
      default: demo
    port:
      default: '8443'
    basePath:
      default: api/v1
paths:
  # some ` + "`" + `comment` + "`" + `
  /: {get: {responses: {default: {}}}}
  /shops: {get: {responses: {default: {}}}}
  /shops/: {get: {responses: {default: {}}}}
  /shops/{shop}: {get: {parameters: [{in: path, name: shop, required: true, schema: {type: string}}], responses: {default: {}}}}
  /shops/{shop}/: {get: {parameters: [{in: path, name: shop, required: true, schema: {type: string}}], responses: {default: {}}}}
  /shops/{shop}/pets: {get: {parameters: [{in: path, name: shop, required: true, schema: {type: string}}], responses: {default: {}}}}
  /shops/{shop}/pets/mike/paws: {get: {parameters: [{in: path, name: shop, required: true, schema: {type: string}}], responses: {default: {}}}}
  /shops/activate: {get: {responses: {default: {}}}}
`

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 {
	GetHandler                      GetHandlerFunc
	GetShopsHandler                 GetShopsHandlerFunc
	GetShopsRTHandler               GetShopsRTHandlerFunc
	GetShopsActivateHandler         GetShopsActivateHandlerFunc
	GetShopsShopHandler             GetShopsShopHandlerFunc
	GetShopsShopRTHandler           GetShopsShopRTHandlerFunc
	GetShopsShopPetsHandler         GetShopsShopPetsHandlerFunc
	GetShopsShopPetsMikePawsHandler GetShopsShopPetsMikePawsHandlerFunc

	// 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) Get added in v0.0.2

func (c *Client) Get(ctx context.Context, request GetParams) (GetResponse, error)

Get - GET /

func (*Client) GetShops added in v0.0.2

func (c *Client) GetShops(ctx context.Context, request GetShopsParams) (GetShopsResponse, error)

GetShops - GET /shops

func (*Client) GetShopsActivate added in v0.0.2

func (c *Client) GetShopsActivate(ctx context.Context, request GetShopsActivateParams) (GetShopsActivateResponse, error)

GetShopsActivate - GET /shops/activate

func (*Client) GetShopsRT added in v0.0.2

func (c *Client) GetShopsRT(ctx context.Context, request GetShopsRTParams) (GetShopsRTResponse, error)

GetShopsRT - GET /shops/

func (*Client) GetShopsShop added in v0.0.2

func (c *Client) GetShopsShop(ctx context.Context, request GetShopsShopParams) (GetShopsShopResponse, error)

GetShopsShop - GET /shops/{shop}

func (*Client) GetShopsShopPets added in v0.0.2

func (c *Client) GetShopsShopPets(ctx context.Context, request GetShopsShopPetsParams) (GetShopsShopPetsResponse, error)

GetShopsShopPets - GET /shops/{shop}/pets

func (*Client) GetShopsShopPetsMikePaws added in v0.0.4

func (c *Client) GetShopsShopPetsMikePaws(ctx context.Context, request GetShopsShopPetsMikePawsParams) (GetShopsShopPetsMikePawsResponse, error)

GetShopsShopPetsMikePaws - GET /shops/{shop}/pets/mike/paws

func (*Client) GetShopsShopRT added in v0.0.2

func (c *Client) GetShopsShopRT(ctx context.Context, request GetShopsShopRTParams) (GetShopsShopRTResponse, error)

GetShopsShopRT - GET /shops/{shop}/

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 GetHandlerFunc added in v0.0.2

type GetHandlerFunc func(r GetRequest) GetResponse

func (GetHandlerFunc) ServeHTTP added in v0.0.2

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

type GetParams added in v0.0.3

type GetParams struct {
}

func (GetParams) HTTP added in v0.0.3

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

func (GetParams) Parse added in v0.0.3

func (r GetParams) Parse() GetParams

type GetRequest added in v0.0.2

type GetRequest interface {
	HTTP() *http.Request
	Parse() GetParams
}

func GetHTTPRequest added in v0.0.2

func GetHTTPRequest(r *http.Request) GetRequest

type GetResponse added in v0.0.2

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

func NewGetResponseDefault added in v0.0.2

func NewGetResponseDefault(code int) GetResponse

type GetResponseDefault added in v0.0.2

type GetResponseDefault struct {
	Code int
}

func (GetResponseDefault) Write added in v0.0.2

type GetShopsActivateHandlerFunc

type GetShopsActivateHandlerFunc func(r GetShopsActivateRequest) GetShopsActivateResponse

func (GetShopsActivateHandlerFunc) ServeHTTP

type GetShopsActivateParams added in v0.0.3

type GetShopsActivateParams struct {
}

func (GetShopsActivateParams) HTTP added in v0.0.3

func (GetShopsActivateParams) Parse added in v0.0.3

type GetShopsActivateRequest

type GetShopsActivateRequest interface {
	HTTP() *http.Request
	Parse() GetShopsActivateParams
}

func GetShopsActivateHTTPRequest added in v0.0.2

func GetShopsActivateHTTPRequest(r *http.Request) GetShopsActivateRequest

type GetShopsActivateResponse added in v0.0.2

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

func NewGetShopsActivateResponseDefault added in v0.0.2

func NewGetShopsActivateResponseDefault(code int) GetShopsActivateResponse

type GetShopsActivateResponseDefault

type GetShopsActivateResponseDefault struct {
	Code int
}

func (GetShopsActivateResponseDefault) Write added in v0.0.2

type GetShopsHandlerFunc

type GetShopsHandlerFunc func(r GetShopsRequest) GetShopsResponse

func (GetShopsHandlerFunc) ServeHTTP

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

type GetShopsParams added in v0.0.3

type GetShopsParams struct {
}

func (GetShopsParams) HTTP added in v0.0.3

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

func (GetShopsParams) Parse added in v0.0.3

func (r GetShopsParams) Parse() GetShopsParams

type GetShopsRTHandlerFunc

type GetShopsRTHandlerFunc func(r GetShopsRTRequest) GetShopsRTResponse

func (GetShopsRTHandlerFunc) ServeHTTP

type GetShopsRTParams added in v0.0.3

type GetShopsRTParams struct {
}

func (GetShopsRTParams) HTTP added in v0.0.3

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

func (GetShopsRTParams) Parse added in v0.0.3

type GetShopsRTRequest

type GetShopsRTRequest interface {
	HTTP() *http.Request
	Parse() GetShopsRTParams
}

func GetShopsRTHTTPRequest added in v0.0.2

func GetShopsRTHTTPRequest(r *http.Request) GetShopsRTRequest

type GetShopsRTResponse added in v0.0.2

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

func NewGetShopsRTResponseDefault added in v0.0.2

func NewGetShopsRTResponseDefault(code int) GetShopsRTResponse

type GetShopsRTResponseDefault

type GetShopsRTResponseDefault struct {
	Code int
}

func (GetShopsRTResponseDefault) Write added in v0.0.2

type GetShopsRequest

type GetShopsRequest interface {
	HTTP() *http.Request
	Parse() GetShopsParams
}

func GetShopsHTTPRequest added in v0.0.2

func GetShopsHTTPRequest(r *http.Request) GetShopsRequest

type GetShopsResponse added in v0.0.2

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

func NewGetShopsResponseDefault added in v0.0.2

func NewGetShopsResponseDefault(code int) GetShopsResponse

type GetShopsResponseDefault

type GetShopsResponseDefault struct {
	Code int
}

func (GetShopsResponseDefault) Write added in v0.0.2

type GetShopsShopHandlerFunc

type GetShopsShopHandlerFunc func(r GetShopsShopRequest) GetShopsShopResponse

func (GetShopsShopHandlerFunc) ServeHTTP

type GetShopsShopParams added in v0.0.3

type GetShopsShopParams struct {
	Path struct {
		Shop string
	}
}

func (GetShopsShopParams) HTTP added in v0.0.3

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

func (GetShopsShopParams) Parse added in v0.0.3

type GetShopsShopPetsHandlerFunc

type GetShopsShopPetsHandlerFunc func(r GetShopsShopPetsRequest) GetShopsShopPetsResponse

func (GetShopsShopPetsHandlerFunc) ServeHTTP

type GetShopsShopPetsMikePawsHandlerFunc added in v0.0.4

type GetShopsShopPetsMikePawsHandlerFunc func(r GetShopsShopPetsMikePawsRequest) GetShopsShopPetsMikePawsResponse

func (GetShopsShopPetsMikePawsHandlerFunc) ServeHTTP added in v0.0.4

type GetShopsShopPetsMikePawsParams added in v0.0.4

type GetShopsShopPetsMikePawsParams struct {
	Path struct {
		Shop string
	}
}

func (GetShopsShopPetsMikePawsParams) HTTP added in v0.0.4

func (GetShopsShopPetsMikePawsParams) Parse added in v0.0.4

type GetShopsShopPetsMikePawsRequest added in v0.0.4

type GetShopsShopPetsMikePawsRequest interface {
	HTTP() *http.Request
	Parse() (GetShopsShopPetsMikePawsParams, error)
}

func GetShopsShopPetsMikePawsHTTPRequest added in v0.0.4

func GetShopsShopPetsMikePawsHTTPRequest(r *http.Request) GetShopsShopPetsMikePawsRequest

type GetShopsShopPetsMikePawsResponse added in v0.0.4

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

func NewGetShopsShopPetsMikePawsResponseDefault added in v0.0.4

func NewGetShopsShopPetsMikePawsResponseDefault(code int) GetShopsShopPetsMikePawsResponse

type GetShopsShopPetsMikePawsResponseDefault added in v0.0.4

type GetShopsShopPetsMikePawsResponseDefault struct {
	Code int
}

func (GetShopsShopPetsMikePawsResponseDefault) Write added in v0.0.4

type GetShopsShopPetsParams added in v0.0.3

type GetShopsShopPetsParams struct {
	Path struct {
		Shop string
	}
}

func (GetShopsShopPetsParams) HTTP added in v0.0.3

func (GetShopsShopPetsParams) Parse added in v0.0.3

type GetShopsShopPetsRequest

type GetShopsShopPetsRequest interface {
	HTTP() *http.Request
	Parse() (GetShopsShopPetsParams, error)
}

func GetShopsShopPetsHTTPRequest added in v0.0.2

func GetShopsShopPetsHTTPRequest(r *http.Request) GetShopsShopPetsRequest

type GetShopsShopPetsResponse added in v0.0.2

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

func NewGetShopsShopPetsResponseDefault added in v0.0.2

func NewGetShopsShopPetsResponseDefault(code int) GetShopsShopPetsResponse

type GetShopsShopPetsResponseDefault

type GetShopsShopPetsResponseDefault struct {
	Code int
}

func (GetShopsShopPetsResponseDefault) Write added in v0.0.2

type GetShopsShopRTHandlerFunc

type GetShopsShopRTHandlerFunc func(r GetShopsShopRTRequest) GetShopsShopRTResponse

func (GetShopsShopRTHandlerFunc) ServeHTTP

type GetShopsShopRTParams added in v0.0.3

type GetShopsShopRTParams struct {
	Path struct {
		Shop string
	}
}

func (GetShopsShopRTParams) HTTP added in v0.0.3

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

func (GetShopsShopRTParams) Parse added in v0.0.3

type GetShopsShopRTRequest

type GetShopsShopRTRequest interface {
	HTTP() *http.Request
	Parse() (GetShopsShopRTParams, error)
}

func GetShopsShopRTHTTPRequest added in v0.0.2

func GetShopsShopRTHTTPRequest(r *http.Request) GetShopsShopRTRequest

type GetShopsShopRTResponse added in v0.0.2

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

func NewGetShopsShopRTResponseDefault added in v0.0.2

func NewGetShopsShopRTResponseDefault(code int) GetShopsShopRTResponse

type GetShopsShopRTResponseDefault

type GetShopsShopRTResponseDefault struct {
	Code int
}

func (GetShopsShopRTResponseDefault) Write added in v0.0.2

type GetShopsShopRequest

type GetShopsShopRequest interface {
	HTTP() *http.Request
	Parse() (GetShopsShopParams, error)
}

func GetShopsShopHTTPRequest added in v0.0.2

func GetShopsShopHTTPRequest(r *http.Request) GetShopsShopRequest

type GetShopsShopResponse added in v0.0.2

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

func NewGetShopsShopResponseDefault added in v0.0.2

func NewGetShopsShopResponseDefault(code int) GetShopsShopResponse

type GetShopsShopResponseDefault

type GetShopsShopResponseDefault struct {
	Code int
}

func (GetShopsShopResponseDefault) Write added in v0.0.2

type HTTPClient added in v0.0.2

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

Jump to

Keyboard shortcuts

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