Documentation
¶
Index ¶
- Constants
- Variables
- func MakeForbidden(err error) *goa.ServiceError
- func MakeInternalError(err error) *goa.ServiceError
- func MakeInvalidParameters(err error) *goa.ServiceError
- func MakeUnauthorized(err error) *goa.ServiceError
- func MakeUserNotFound(err error) *goa.ServiceError
- func MakeUsernameTaken(err error) *goa.ServiceError
- func NewAuthUserEndpoint(s Service) goa.Endpoint
- func NewCreateUserEndpoint(s Service) goa.Endpoint
- func NewDeleteUserEndpoint(s Service) goa.Endpoint
- func NewGetOperatorTokenEndpoint(s Service) goa.Endpoint
- func NewListUsersEndpoint(s Service) goa.Endpoint
- func WrapDeleteUserEndpoint(endpoint goa.Endpoint, i ServerInterceptors) goa.Endpoint
- func WrapGetOperatorTokenEndpoint(endpoint goa.Endpoint, i ServerInterceptors) goa.Endpoint
- func WrapListUsersEndpoint(endpoint goa.Endpoint, i ServerInterceptors) goa.Endpoint
- type AuthUserPayload
- type AuthUserResult
- type AuthentifiedInfo
- type Client
- func (c *Client) AuthUser(ctx context.Context, p *AuthUserPayload) (res *AuthUserResult, err error)
- func (c *Client) CreateUser(ctx context.Context, p *CreateUserPayload) (res *CreateUserResult, err error)
- func (c *Client) DeleteUser(ctx context.Context, p *DeleteUserPayload) (err error)
- func (c *Client) GetOperatorToken(ctx context.Context) (res *GetOperatorTokenResult, err error)
- func (c *Client) ListUsers(ctx context.Context) (res []*User, err error)
- type CreateUserPayload
- type CreateUserResult
- type DeleteUserPayload
- type Endpoints
- type GetOperatorTokenResult
- type IsAdminInfo
- type Role
- type ServerInterceptors
- type Service
- type User
Constants ¶
const APIName = "fishykeys"
APIName is the name of the API as defined in the design.
const APIVersion = "1.0"
APIVersion is the version of the API as defined in the design.
const ServiceName = "users"
ServiceName is the name of the service as defined in the design. This is the same value that is set in the endpoint request contexts under the ServiceKey key.
Variables ¶
var MethodNames = [5]string{"create user", "list users", "delete user", "auth user", "get operator token"}
MethodNames lists the service method names as defined in the design. These are the same values that are set in the endpoint request contexts under the MethodKey key.
Functions ¶
func MakeForbidden ¶
func MakeForbidden(err error) *goa.ServiceError
MakeForbidden builds a goa.ServiceError from an error.
func MakeInternalError ¶
func MakeInternalError(err error) *goa.ServiceError
MakeInternalError builds a goa.ServiceError from an error.
func MakeInvalidParameters ¶
func MakeInvalidParameters(err error) *goa.ServiceError
MakeInvalidParameters builds a goa.ServiceError from an error.
func MakeUnauthorized ¶
func MakeUnauthorized(err error) *goa.ServiceError
MakeUnauthorized builds a goa.ServiceError from an error.
func MakeUserNotFound ¶
func MakeUserNotFound(err error) *goa.ServiceError
MakeUserNotFound builds a goa.ServiceError from an error.
func MakeUsernameTaken ¶
func MakeUsernameTaken(err error) *goa.ServiceError
MakeUsernameTaken builds a goa.ServiceError from an error.
func NewAuthUserEndpoint ¶
NewAuthUserEndpoint returns an endpoint function that calls the method "auth user" of service "users".
func NewCreateUserEndpoint ¶
NewCreateUserEndpoint returns an endpoint function that calls the method "create user" of service "users".
func NewDeleteUserEndpoint ¶
NewDeleteUserEndpoint returns an endpoint function that calls the method "delete user" of service "users".
func NewGetOperatorTokenEndpoint ¶
NewGetOperatorTokenEndpoint returns an endpoint function that calls the method "get operator token" of service "users".
func NewListUsersEndpoint ¶
NewListUsersEndpoint returns an endpoint function that calls the method "list users" of service "users".
func WrapDeleteUserEndpoint ¶
func WrapDeleteUserEndpoint(endpoint goa.Endpoint, i ServerInterceptors) goa.Endpoint
WrapDeleteUserEndpoint wraps the delete user endpoint with the server-side interceptors defined in the design.
func WrapGetOperatorTokenEndpoint ¶
func WrapGetOperatorTokenEndpoint(endpoint goa.Endpoint, i ServerInterceptors) goa.Endpoint
WrapGetOperatorTokenEndpoint wraps the get operator token endpoint with the server-side interceptors defined in the design.
func WrapListUsersEndpoint ¶
func WrapListUsersEndpoint(endpoint goa.Endpoint, i ServerInterceptors) goa.Endpoint
WrapListUsersEndpoint wraps the list users endpoint with the server-side interceptors defined in the design.
Types ¶
type AuthUserPayload ¶
AuthUserPayload is the payload type of the users service auth user method.
type AuthUserResult ¶
type AuthUserResult struct {
// The username of the authenticated user
Username *string
// JWT or session token
Token *string
}
AuthUserResult is the result type of the users service auth user method.
type AuthentifiedInfo ¶
type AuthentifiedInfo struct {
// contains filtered or unexported fields
}
AuthentifiedInfo provides metadata about the current interception. It includes service name, method name, and access to the endpoint.
func (*AuthentifiedInfo) CallType ¶
func (info *AuthentifiedInfo) CallType() goa.InterceptorCallType
CallType returns the type of call the interceptor is handling.
func (*AuthentifiedInfo) Method ¶
func (info *AuthentifiedInfo) Method() string
Method returns the name of the method handling the request.
func (*AuthentifiedInfo) RawPayload ¶
func (info *AuthentifiedInfo) RawPayload() any
RawPayload returns the raw payload of the request.
func (*AuthentifiedInfo) Service ¶
func (info *AuthentifiedInfo) Service() string
Service returns the name of the service handling the request.
type Client ¶
type Client struct {
CreateUserEndpoint goa.Endpoint
ListUsersEndpoint goa.Endpoint
DeleteUserEndpoint goa.Endpoint
AuthUserEndpoint goa.Endpoint
GetOperatorTokenEndpoint goa.Endpoint
}
Client is the "users" service client.
func (*Client) AuthUser ¶
func (c *Client) AuthUser(ctx context.Context, p *AuthUserPayload) (res *AuthUserResult, err error)
AuthUser calls the "auth user" endpoint of the "users" service. AuthUser may return the following errors:
- "unauthorized" (type *goa.ServiceError): Invalid username or password
- "invalid_parameters" (type *goa.ServiceError): Invalid input
- "internal_error" (type *goa.ServiceError): Internal server error
- error: internal error
func (*Client) CreateUser ¶
func (c *Client) CreateUser(ctx context.Context, p *CreateUserPayload) (res *CreateUserResult, err error)
CreateUser calls the "create user" endpoint of the "users" service. CreateUser may return the following errors:
- "username_taken" (type *goa.ServiceError): Username already exists
- "invalid_parameters" (type *goa.ServiceError): Invalid input
- "internal_error" (type *goa.ServiceError): Internal server error
- error: internal error
func (*Client) DeleteUser ¶
func (c *Client) DeleteUser(ctx context.Context, p *DeleteUserPayload) (err error)
DeleteUser calls the "delete user" endpoint of the "users" service. DeleteUser may return the following errors:
- "user_not_found" (type *goa.ServiceError): User not found
- "invalid_parameters" (type *goa.ServiceError): Invalid input
- "internal_error" (type *goa.ServiceError): Internal server error
- "forbidden" (type *goa.ServiceError): Forbidden access
- "unauthorized" (type *goa.ServiceError): Unauthorized access
- error: internal error
func (*Client) GetOperatorToken ¶
func (c *Client) GetOperatorToken(ctx context.Context) (res *GetOperatorTokenResult, err error)
GetOperatorToken calls the "get operator token" endpoint of the "users" service. GetOperatorToken may return the following errors:
- "internal_error" (type *goa.ServiceError): Internal server error
- error: internal error
type CreateUserPayload ¶
type CreateUserPayload struct {
// Username of the new user
Username string
// Password (hashed or plain depending on implementation)
Password string
}
CreateUserPayload is the payload type of the users service create user method.
type CreateUserResult ¶
type CreateUserResult struct {
// The username of the created user
Username string
// Unique identifier for the user
ID int
}
CreateUserResult is the result type of the users service create user method.
type DeleteUserPayload ¶
type DeleteUserPayload struct {
// Username of the user to delete
Username string
}
DeleteUserPayload is the payload type of the users service delete user method.
type Endpoints ¶
type Endpoints struct {
CreateUser goa.Endpoint
ListUsers goa.Endpoint
DeleteUser goa.Endpoint
AuthUser goa.Endpoint
GetOperatorToken goa.Endpoint
}
Endpoints wraps the "users" service endpoints.
func NewEndpoints ¶
func NewEndpoints(s Service, si ServerInterceptors) *Endpoints
NewEndpoints wraps the methods of the "users" service with endpoints.
type GetOperatorTokenResult ¶
type GetOperatorTokenResult struct {
// The username of the account corresponding to the token
Username *string
// JWT or session token
Token *string
}
GetOperatorTokenResult is the result type of the users service get operator token method.
type IsAdminInfo ¶
type IsAdminInfo struct {
// contains filtered or unexported fields
}
IsAdminInfo provides metadata about the current interception. It includes service name, method name, and access to the endpoint.
func (*IsAdminInfo) CallType ¶
func (info *IsAdminInfo) CallType() goa.InterceptorCallType
CallType returns the type of call the interceptor is handling.
func (*IsAdminInfo) Method ¶
func (info *IsAdminInfo) Method() string
Method returns the name of the method handling the request.
func (*IsAdminInfo) RawPayload ¶
func (info *IsAdminInfo) RawPayload() any
RawPayload returns the raw payload of the request.
func (*IsAdminInfo) Service ¶
func (info *IsAdminInfo) Service() string
Service returns the name of the service handling the request.
type ServerInterceptors ¶
type ServerInterceptors interface {
// Server-side interceptor that validates JWT token for HTTP services
Authentified(ctx context.Context, info *AuthentifiedInfo, next goa.Endpoint) (any, error)
// Server-side interceptor that checks if the user has admin privileges
IsAdmin(ctx context.Context, info *IsAdminInfo, next goa.Endpoint) (any, error)
}
ServerInterceptors defines the interface for all server-side interceptors. Server interceptors execute after the request is decoded and before the payload is sent to the service. The implementation is responsible for calling next to complete the request.
type Service ¶
type Service interface {
// Create a new user
CreateUser(context.Context, *CreateUserPayload) (res *CreateUserResult, err error)
// List all users
ListUsers(context.Context) (res []*User, err error)
// Delete a user by username
DeleteUser(context.Context, *DeleteUserPayload) (err error)
// Authenticate a user with username and password
AuthUser(context.Context, *AuthUserPayload) (res *AuthUserResult, err error)
// Retrieve a JWT token that doesn't expire for operator use, corresponding to
// your user
GetOperatorToken(context.Context) (res *GetOperatorTokenResult, err error)
}
User service manages user accounts and authentication