Documentation
¶
Overview ¶
Package example holds the client that the tests of the generator drive. The generated file beside it is the output of `avero generate`. See the SDD, S13.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Example ¶
type Example interface {
//avero:GET /things/{id}
GetThing(ctx context.Context, id string) (Thing, error)
//avero:GET /things
ListThings(ctx context.Context, opts ListOptions) (List, error)
//avero:POST /things
CreateThing(ctx context.Context, body NewThing) (*Thing, error)
//avero:DELETE /things/{id}
DeleteThing(ctx context.Context, id string) error
//avero:GET /accounts/{account}/things/{id}
GetAccountThing(ctx context.Context, account int, id string) (Thing, error)
}
Example is the interface that the directive turns into a client. The generated implementation lives in the file beside this one.
func NewExample ¶
NewExample returns a client of the Example service.
The directive states the base address https://api.example.com. An option after it replaces a default, so a test points the client at httptest.
type List ¶
type List struct {
// Things holds the page.
Things []Thing `json:"things"`
// Total is the number of rows of the whole set.
Total int `json:"total"`
}
List is the answer of a list call.
type ListOptions ¶
type ListOptions struct {
// Page is the page number.
Page int `query:"page"`
// Search filters the set. An empty value sends no parameter.
Search string `query:"q,omitempty"`
// Full asks for the whole row.
Full bool `query:"full"`
// Limit bounds the page. A nil value sends no parameter.
Limit *int `query:"limit"`
// Key is the API key of the caller.
Key string `header:"X-Api-Key"`
// Trace names the call in the log of the service.
Trace string `header:"X-Trace,omitempty"`
}
ListOptions holds the query of a list call and the headers of the request.
Click to show internal directories.
Click to hide internal directories.