 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
- Variables
- func BuildNextURL(u url.URL, i interface{}) (url.URL, error)
- func NewRouter(routes Routes) *mux.Router
- func WriteAPIErrorResponse(w http.ResponseWriter, err error)
- func WriteAPIResponse(w http.ResponseWriter, status int, body interface{})
- type Controller
- type Route
- type Router
- type Routes
- type User
- type UserDetailer
- type UserDetails
- type UserDetailsMiddleware
Constants ¶
const AdminGroupName = "Admin"
    AdminGroupName - Has a string to define Admins
const DceCtxKey dceCtxKeyType = "dce"
    DceCtxKey - Context Key
const UserGroupName = "User"
    UserGroupName - Has the string to define Users
Variables ¶
var EmptyQueryString []string
    EmptyQueryString - Empty query string to prevent
Functions ¶
func BuildNextURL ¶
BuildNextURL merges the next parameters of pagination into the request parameters and returns an API URL.
func WriteAPIErrorResponse ¶
func WriteAPIErrorResponse(w http.ResponseWriter, err error)
WriteAPIErrorResponse writes an error to the ResponseWriter
func WriteAPIResponse ¶
func WriteAPIResponse(w http.ResponseWriter, status int, body interface{})
WriteAPIResponse writes the response out to the provided ResponseWriter
Types ¶
type Controller ¶
type Controller interface {
	// Call is invoked when an instance of a controller is handling a request. Returns a response to be returned to the
	// API consumer.
	Call(ctx context.Context, req *events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
}
    Controller is the base controller interface for API Gateway Lambda handlers.
type Route ¶
type Route struct {
	Name        string
	Method      string
	Pattern     string
	Queries     []string
	HandlerFunc http.HandlerFunc
}
    Route - A route
type Router ¶
type Router struct {
	ResourceName     string
	ListController   Controller
	DeleteController Controller
	GetController    Controller
	CreateController Controller
	UserDetails      UserDetailer
}
    Router structure holds AccountController instance for request
func (*Router) Route ¶
func (router *Router) Route(ctx context.Context, req *events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
Route - provides a router for the given resource
type UserDetailer ¶
type UserDetailer interface {
	GetUser(reqCtx *events.APIGatewayProxyRequestContext) *User
}
    UserDetailer - used for mocking tests
type UserDetails ¶
type UserDetails struct {
	CognitoUserPoolID        string `env:"COGNITO_USER_POOL_ID" defaultEnv:"DefaultCognitoUserPoolId"`
	RolesAttributesAdminName string `env:"COGNITO_ROLES_ATTRIBUTE_ADMIN_NAME" defaultEnv:"DefaultCognitoAdminName"`
	CognitoClient            awsiface.CognitoIdentityProviderAPI
}
    UserDetails - Gets User information
func (*UserDetails) GetUser ¶
func (u *UserDetails) GetUser(reqCtx *events.APIGatewayProxyRequestContext) *User
GetUser - Gets the username and role out of an http request object Assumes that the request is via a Lambda event. Uses cognito metadata from the request to determine the user info. If the request is not authenticated with cognito, returns a generic admin user: User{ Username: "", Role: "Admin" }
type UserDetailsMiddleware ¶
type UserDetailsMiddleware struct {
	GorillaMuxAdapter *gorillamux.GorillaMuxAdapter
	UserDetailer      UserDetailer
}
    func (*UserDetailsMiddleware) Middleware ¶
func (u *UserDetailsMiddleware) Middleware(next http.Handler) http.Handler