Documentation ¶
Index ¶
- Variables
- func GetFailures(name string) map[error]interface{}
- func MakeEndpointOfDeleteAddress(s Service) endpoint.Endpoint
- func MakeEndpointOfDeleteProfile(s Service) endpoint.Endpoint
- func MakeEndpointOfGetAddress(s Service) endpoint.Endpoint
- func MakeEndpointOfGetAddresses(s Service) endpoint.Endpoint
- func MakeEndpointOfGetProfile(s Service) endpoint.Endpoint
- func MakeEndpointOfPatchProfile(s Service) endpoint.Endpoint
- func MakeEndpointOfPostAddress(s Service) endpoint.Endpoint
- func MakeEndpointOfPostProfile(s Service) endpoint.Endpoint
- func MakeEndpointOfPutProfile(s Service) endpoint.Endpoint
- func NewCodecs() *httpcodec.DefaultCodecs
- func NewHTTPRouter(svc Service, codecs httpcodec.Codecs, opts ...httpoption.Option) chi.Router
- func NewSchema() *oas2.ResponseSchema
- func OASv2APIDoc(schema oas2.Schema) string
- func ValidateDeleteAddressRequest(newSchema func(*DeleteAddressRequest) validating.Schema) httpoption.Validator
- func ValidateDeleteProfileRequest(newSchema func(*DeleteProfileRequest) validating.Schema) httpoption.Validator
- func ValidateGetAddressRequest(newSchema func(*GetAddressRequest) validating.Schema) httpoption.Validator
- func ValidateGetAddressesRequest(newSchema func(*GetAddressesRequest) validating.Schema) httpoption.Validator
- func ValidateGetProfileRequest(newSchema func(*GetProfileRequest) validating.Schema) httpoption.Validator
- func ValidatePatchProfileRequest(newSchema func(*PatchProfileRequest) validating.Schema) httpoption.Validator
- func ValidatePostAddressRequest(newSchema func(*PostAddressRequest) validating.Schema) httpoption.Validator
- func ValidatePostProfileRequest(newSchema func(*PostProfileRequest) validating.Schema) httpoption.Validator
- func ValidatePutProfileRequest(newSchema func(*PutProfileRequest) validating.Schema) httpoption.Validator
- type Address
- type Codec
- type DeleteAddressRequest
- type DeleteAddressResponse
- type DeleteProfileRequest
- type DeleteProfileResponse
- type GetAddressRequest
- type GetAddressResponse
- type GetAddressesRequest
- type GetAddressesResponse
- type GetProfileRequest
- type GetProfileResponse
- type HTTPClient
- func (c *HTTPClient) DeleteAddress(ctx context.Context, id string, addressID string) (err error)
- func (c *HTTPClient) DeleteProfile(ctx context.Context, id string) (err error)
- func (c *HTTPClient) GetAddress(ctx context.Context, id string, addressID string) (address Address, err error)
- func (c *HTTPClient) GetAddresses(ctx context.Context, id string) (addresses []Address, err error)
- func (c *HTTPClient) GetProfile(ctx context.Context, id string) (profile Profile, err error)
- func (c *HTTPClient) PatchProfile(ctx context.Context, id string, profile Profile) (err error)
- func (c *HTTPClient) PostAddress(ctx context.Context, id string, address Address) (err error)
- func (c *HTTPClient) PostProfile(ctx context.Context, profile Profile) (err error)
- func (c *HTTPClient) PutProfile(ctx context.Context, id string, profile Profile) (err error)
- type PatchProfileRequest
- type PatchProfileResponse
- type PostAddressRequest
- type PostAddressResponse
- type PostProfileRequest
- type PostProfileResponse
- type Profile
- type PutProfileRequest
- type PutProfileResponse
- type Service
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func GetFailures ¶
func MakeEndpointOfDeleteAddress ¶
MakeEndpointOfDeleteAddress creates the endpoint for s.DeleteAddress.
func MakeEndpointOfDeleteProfile ¶
MakeEndpointOfDeleteProfile creates the endpoint for s.DeleteProfile.
func MakeEndpointOfGetAddress ¶
MakeEndpointOfGetAddress creates the endpoint for s.GetAddress.
func MakeEndpointOfGetAddresses ¶
MakeEndpointOfGetAddresses creates the endpoint for s.GetAddresses.
func MakeEndpointOfGetProfile ¶
MakeEndpointOfGetProfile creates the endpoint for s.GetProfile.
func MakeEndpointOfPatchProfile ¶
MakeEndpointOfPatchProfile creates the endpoint for s.PatchProfile.
func MakeEndpointOfPostAddress ¶
MakeEndpointOfPostAddress creates the endpoint for s.PostAddress.
func MakeEndpointOfPostProfile ¶
MakeEndpointOfPostProfile creates the endpoint for s.PostProfile.
func MakeEndpointOfPutProfile ¶
MakeEndpointOfPutProfile creates the endpoint for s.PutProfile.
func NewCodecs ¶
func NewCodecs() *httpcodec.DefaultCodecs
func NewHTTPRouter ¶
func NewSchema ¶
func NewSchema() *oas2.ResponseSchema
func OASv2APIDoc ¶
func ValidateDeleteAddressRequest ¶
func ValidateDeleteAddressRequest(newSchema func(*DeleteAddressRequest) validating.Schema) httpoption.Validator
ValidateDeleteAddressRequest creates a validator for DeleteAddressRequest.
func ValidateDeleteProfileRequest ¶
func ValidateDeleteProfileRequest(newSchema func(*DeleteProfileRequest) validating.Schema) httpoption.Validator
ValidateDeleteProfileRequest creates a validator for DeleteProfileRequest.
func ValidateGetAddressRequest ¶
func ValidateGetAddressRequest(newSchema func(*GetAddressRequest) validating.Schema) httpoption.Validator
ValidateGetAddressRequest creates a validator for GetAddressRequest.
func ValidateGetAddressesRequest ¶
func ValidateGetAddressesRequest(newSchema func(*GetAddressesRequest) validating.Schema) httpoption.Validator
ValidateGetAddressesRequest creates a validator for GetAddressesRequest.
func ValidateGetProfileRequest ¶
func ValidateGetProfileRequest(newSchema func(*GetProfileRequest) validating.Schema) httpoption.Validator
ValidateGetProfileRequest creates a validator for GetProfileRequest.
func ValidatePatchProfileRequest ¶
func ValidatePatchProfileRequest(newSchema func(*PatchProfileRequest) validating.Schema) httpoption.Validator
ValidatePatchProfileRequest creates a validator for PatchProfileRequest.
func ValidatePostAddressRequest ¶
func ValidatePostAddressRequest(newSchema func(*PostAddressRequest) validating.Schema) httpoption.Validator
ValidatePostAddressRequest creates a validator for PostAddressRequest.
func ValidatePostProfileRequest ¶
func ValidatePostProfileRequest(newSchema func(*PostProfileRequest) validating.Schema) httpoption.Validator
ValidatePostProfileRequest creates a validator for PostProfileRequest.
func ValidatePutProfileRequest ¶
func ValidatePutProfileRequest(newSchema func(*PutProfileRequest) validating.Schema) httpoption.Validator
ValidatePutProfileRequest creates a validator for PutProfileRequest.
Types ¶
type Address ¶
Address is a field of a user profile. ID should be unique within the profile (at a minimum).
type Codec ¶
func (Codec) EncodeFailureResponse ¶
func (c Codec) EncodeFailureResponse(w http.ResponseWriter, err error) error
type DeleteAddressRequest ¶
type DeleteAddressResponse ¶
type DeleteAddressResponse struct {
Err error `json:"-"`
}
func (*DeleteAddressResponse) Body ¶
func (r *DeleteAddressResponse) Body() interface{}
func (*DeleteAddressResponse) Failed ¶
func (r *DeleteAddressResponse) Failed() error
Failed implements endpoint.Failer.
type DeleteProfileRequest ¶
type DeleteProfileRequest struct {
Id string `json:"-"`
}
type DeleteProfileResponse ¶
type DeleteProfileResponse struct {
Err error `json:"-"`
}
func (*DeleteProfileResponse) Body ¶
func (r *DeleteProfileResponse) Body() interface{}
func (*DeleteProfileResponse) Failed ¶
func (r *DeleteProfileResponse) Failed() error
Failed implements endpoint.Failer.
type GetAddressRequest ¶
type GetAddressResponse ¶
func (*GetAddressResponse) Body ¶
func (r *GetAddressResponse) Body() interface{}
func (*GetAddressResponse) Failed ¶
func (r *GetAddressResponse) Failed() error
Failed implements endpoint.Failer.
type GetAddressesRequest ¶
type GetAddressesRequest struct {
Id string `json:"-"`
}
type GetAddressesResponse ¶
func (*GetAddressesResponse) Body ¶
func (r *GetAddressesResponse) Body() interface{}
func (*GetAddressesResponse) Failed ¶
func (r *GetAddressesResponse) Failed() error
Failed implements endpoint.Failer.
type GetProfileRequest ¶
type GetProfileRequest struct {
Id string `json:"-"`
}
type GetProfileResponse ¶
func (*GetProfileResponse) Body ¶
func (r *GetProfileResponse) Body() interface{}
func (*GetProfileResponse) Failed ¶
func (r *GetProfileResponse) Failed() error
Failed implements endpoint.Failer.
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
func NewHTTPClient ¶
func (*HTTPClient) DeleteAddress ¶
func (*HTTPClient) DeleteProfile ¶
func (c *HTTPClient) DeleteProfile(ctx context.Context, id string) (err error)
func (*HTTPClient) GetAddress ¶
func (*HTTPClient) GetAddresses ¶
func (*HTTPClient) GetProfile ¶
func (*HTTPClient) PatchProfile ¶
func (*HTTPClient) PostAddress ¶
func (*HTTPClient) PostProfile ¶
func (c *HTTPClient) PostProfile(ctx context.Context, profile Profile) (err error)
func (*HTTPClient) PutProfile ¶
type PatchProfileRequest ¶
type PatchProfileResponse ¶
type PatchProfileResponse struct {
Err error `json:"-"`
}
func (*PatchProfileResponse) Body ¶
func (r *PatchProfileResponse) Body() interface{}
func (*PatchProfileResponse) Failed ¶
func (r *PatchProfileResponse) Failed() error
Failed implements endpoint.Failer.
type PostAddressRequest ¶
type PostAddressResponse ¶
type PostAddressResponse struct {
Err error `json:"-"`
}
func (*PostAddressResponse) Body ¶
func (r *PostAddressResponse) Body() interface{}
func (*PostAddressResponse) Failed ¶
func (r *PostAddressResponse) Failed() error
Failed implements endpoint.Failer.
type PostProfileRequest ¶
type PostProfileRequest struct {
Profile Profile `json:"profile"`
}
type PostProfileResponse ¶
type PostProfileResponse struct {
Err error `json:"-"`
}
func (*PostProfileResponse) Body ¶
func (r *PostProfileResponse) Body() interface{}
func (*PostProfileResponse) Failed ¶
func (r *PostProfileResponse) Failed() error
Failed implements endpoint.Failer.
type Profile ¶
type Profile struct { ID string `json:"id"` Name string `json:"name,omitempty"` Addresses []Address `json:"addresses,omitempty"` }
Profile represents a single user profile. ID should be globally unique.
type PutProfileRequest ¶
type PutProfileResponse ¶
type PutProfileResponse struct {
Err error `json:"-"`
}
func (*PutProfileResponse) Body ¶
func (r *PutProfileResponse) Body() interface{}
func (*PutProfileResponse) Failed ¶
func (r *PutProfileResponse) Failed() error
Failed implements endpoint.Failer.
type Service ¶
type Service interface { //kun:op POST /profiles PostProfile(ctx context.Context, profile Profile) (err error) //kun:op GET /profiles/{id} GetProfile(ctx context.Context, id string) (profile Profile, err error) //kun:op PUT /profiles/{id} PutProfile(ctx context.Context, id string, profile Profile) (err error) //kun:op PATCH /profiles/{id} PatchProfile(ctx context.Context, id string, profile Profile) (err error) //kun:op DELETE /profiles/{id} DeleteProfile(ctx context.Context, id string) (err error) //kun:op GET /profiles/{id}/addresses GetAddresses(ctx context.Context, id string) (addresses []Address, err error) //kun:op GET /profiles/{id}/addresses/{addressID} GetAddress(ctx context.Context, id string, addressID string) (address Address, err error) //kun:op POST /profiles/{id}/addresses PostAddress(ctx context.Context, id string, address Address) (err error) //kun:op DELETE /profiles/{id}/addresses/{addressID} DeleteAddress(ctx context.Context, id string, addressID string) (err error) }
Service is a simple CRUD interface for user profiles.
func NewInmemService ¶
func NewInmemService() Service