Documentation ¶
Index ¶
- Variables
- func MakeCreateEndpoint(s Service) endpoint.Endpoint
- func MakeDeleteEndpoint(s Service) endpoint.Endpoint
- func MakeGetByIDEndpoint(s Service) endpoint.Endpoint
- func MakeGetByUserIDEndpoint(s Service) endpoint.Endpoint
- func MakeHTTPHandler(e Endpoints, log logger) http.Handler
- func NewError(err error) *httpencoder.ErrorResponse
- type Client
- type ClientResponse
- type CreateRequest
- type Endpoints
- type Service
Constants ¶
This section is empty.
Variables ¶
var ( ErrClientNotFound = errors.New("user_not_found") ErrInvalidRequest = errors.New("invalid_request") ErrInvalidParameter = errors.New("invalid_parameter") ErrForbidden = errors.New("forbidden") )
Predefined errors.
var ErrorCodes = map[error]int{ ErrClientNotFound: http.StatusNotFound, ErrInvalidRequest: http.StatusBadRequest, ErrInvalidParameter: http.StatusBadRequest, ErrForbidden: http.StatusForbidden, }
Error codes map
var ErrorMessages = map[error]string{ ErrClientNotFound: "Client not found", ErrInvalidRequest: "Invalid request", ErrInvalidParameter: "Invalid parameter", ErrForbidden: "Forbidden action", }
Error messages
Functions ¶
func MakeCreateEndpoint ¶
MakeCreateEndpoint returns an endpoint via the passed service.
func MakeDeleteEndpoint ¶
MakeDeleteEndpoint returns an endpoint via the passed service.
func MakeGetByIDEndpoint ¶
MakeGetByIDEndpoint returns an endpoint via the passed service.
func MakeGetByUserIDEndpoint ¶
MakeGetByUserIDEndpoint returns an endpoint via the passed service.
func MakeHTTPHandler ¶
MakeHTTPHandler ...
Types ¶
type Client ¶
type Client struct { ID string `json:"id"` Secret string `json:"secret,omitempty"` Domain string `json:"domain"` Public bool `json:"is_public"` UserID string `json:"user_id"` CreatedAt string `json:"created_at"` }
Client represents an OAuth client.
type ClientResponse ¶
type CreateRequest ¶
type CreateRequest struct { Domain string `json:"domain" validate:"required|fullUrl" filter:"trim|lower|escapeJs|escapeHtml" label:"Domain"` Public bool `json:"is_public" validate:"bool" label:"Is Public"` }
CreateRequest is a request for the Create method.
type Endpoints ¶
type Endpoints struct { Create endpoint.Endpoint GetByID endpoint.Endpoint GetByUserID endpoint.Endpoint Delete endpoint.Endpoint }
Endpoints collects all of the endpoints that compose a client service. It's meant to be used as a helper struct, to collect all of the endpoints into a single parameter.
func MakeEndpoints ¶
func MakeEndpoints(s Service, m ...endpoint.Middleware) Endpoints
MakeEndpoints returns an Endpoints struct where each endpoint invokes the corresponding method on the provided service. Primarily useful in a server.
type Service ¶
type Service interface { // Create creates a new client. Create(ctx context.Context, uid string, domain string, isPublic bool) (*Client, error) // GetByID returns a client by its ID. GetByID(ctx context.Context, id string) (*Client, error) // GetByUserID returns a clients list by its user ID. GetByUserID(ctx context.Context, uid string) ([]*Client, error) // Delete deletes a client by its ID. Delete(ctx context.Context, id string) error }
Service is the client service interface.
func NewService ¶
func NewService(repo clientRepository) Service
NewService returns a new instance of a service.