Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
func NewController ¶
func NewController(repo UserRepository) *Controller
func (*Controller) GetUsers ¶
func (c *Controller) GetUsers() http.HandlerFunc
Returns a function that handles GET requests to /users
func (*Controller) RegisterRoutes ¶
func (c *Controller) RegisterRoutes(router *chi.Mux)
func (*Controller) UserAuthenticationMiddleware ¶
func (c *Controller) UserAuthenticationMiddleware(version string, exceptions []string) func(next http.Handler) http.Handler
Middleware which creates the users table if it doesn't exist, and then ensures the `X-Ms-Client-Principal-Id` header is present and check if the user is in the database
type User ¶
type User struct { // An identifier for the caller set by the identity provider. PrincipalId string `json:"X-Ms-Client-Principal-Id"` // A human-readable name for the caller set by the identity provider. PrincipalName string `json:"X-Ms-Client-Principal-Name"` // The name of the identity provider used by App Service Authentication. PrincipalProvider string `json:"X-Ms-Client-Principal-Idp"` // Application Access Level AccessLevel AuthCode `json:"access_level"` }
User represents a user in the database
type UserMSSQL ¶
type UserMSSQL struct {
// contains filtered or unexported fields
}
func (*UserMSSQL) InsertUser ¶
InsertUser inserts a new user into the database
type UserRepository ¶
type UserRepository interface { InsertUser(User) error GetUsers() ([]User, error) GetUser(string) (User, error) }
func NewRepository ¶
func NewRepository(db *sql.DB) UserRepository
Click to show internal directories.
Click to hide internal directories.