Documentation
¶
Index ¶
- Constants
- type Actor
- type Intermediate
- type Mock
- func (svc *Mock) AdminOnly(w http.ResponseWriter, r *http.Request) (err error)
- func (svc *Mock) Login(w http.ResponseWriter, r *http.Request) (err error)
- func (svc *Mock) Logout(w http.ResponseWriter, r *http.Request) (err error)
- func (svc *Mock) ManagerOnly(w http.ResponseWriter, r *http.Request) (err error)
- func (svc *Mock) MockAdminOnly(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock
- func (svc *Mock) MockLogin(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock
- func (svc *Mock) MockLogout(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock
- func (svc *Mock) MockManagerOnly(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock
- func (svc *Mock) MockWelcome(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock
- func (svc *Mock) OnShutdown(ctx context.Context) (err error)
- func (svc *Mock) OnStartup(ctx context.Context) (err error)
- func (svc *Mock) Welcome(w http.ResponseWriter, r *http.Request) (err error)
- type Service
- func (svc *Service) AdminOnly(w http.ResponseWriter, r *http.Request) (err error)
- func (svc *Service) Init(initializer func(svc *Service) (err error)) *Service
- func (svc *Service) Login(w http.ResponseWriter, r *http.Request) (err error)
- func (svc *Service) Logout(w http.ResponseWriter, r *http.Request) (err error)
- func (svc *Service) ManagerOnly(w http.ResponseWriter, r *http.Request) (err error)
- func (svc *Service) OnShutdown(ctx context.Context) (err error)
- func (svc *Service) OnStartup(ctx context.Context) (err error)
- func (svc *Service) Welcome(w http.ResponseWriter, r *http.Request) (err error)
- type ToDo
Constants ¶
const ( Hostname = loginapi.Hostname Version = 92 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Actor ¶
Actor represents the authenticated user. It is parsed from the claims associated with the request.
func (*Actor) SetManager ¶
func (a *Actor) SetManager()
SetManager claims the manager role for the actor.
type Intermediate ¶ added in v1.22.0
Intermediate extends and customizes the generic base connector.
func NewIntermediate ¶ added in v1.22.0
func NewIntermediate(impl ToDo) *Intermediate
NewIntermediate creates a new instance of the intermediate.
type Mock ¶
type Mock struct {
*Intermediate
// contains filtered or unexported fields
}
Mock is a mockable version of the microservice, allowing functions, event sinks and web handlers to be mocked.
func (*Mock) ManagerOnly ¶ added in v1.22.0
ManagerOnly executes the mock handler.
func (*Mock) MockAdminOnly ¶ added in v1.22.0
func (svc *Mock) MockAdminOnly(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock
MockAdminOnly sets up a mock handler for AdminOnly.
func (*Mock) MockLogout ¶ added in v1.22.0
MockLogout sets up a mock handler for Logout.
func (*Mock) MockManagerOnly ¶ added in v1.22.0
func (svc *Mock) MockManagerOnly(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock
MockManagerOnly sets up a mock handler for ManagerOnly.
func (*Mock) MockWelcome ¶ added in v1.22.0
func (svc *Mock) MockWelcome(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock
MockWelcome sets up a mock handler for Welcome.
func (*Mock) OnShutdown ¶ added in v1.22.0
OnShutdown is called when the microservice is shut down.
type Service ¶
type Service struct {
*Intermediate // IMPORTANT: Do not remove
}
Service implements the login.example microservice.
The Login microservice demonstrates usage of authentication and authorization.
func (*Service) Login ¶
Login renders a simple login screen that authenticates a user. Known users are hardcoded as "admin", "manager" and "user". The password is "password".
func (*Service) ManagerOnly ¶
ManagerOnly is only accessible by managers.
func (*Service) OnShutdown ¶
OnShutdown is called when the microservice is shut down.
type ToDo ¶ added in v1.22.0
type ToDo interface {
OnStartup(ctx context.Context) (err error)
OnShutdown(ctx context.Context) (err error)
Login(w http.ResponseWriter, r *http.Request) (err error) // MARKER: Login
Logout(w http.ResponseWriter, r *http.Request) (err error) // MARKER: Logout
Welcome(w http.ResponseWriter, r *http.Request) (err error) // MARKER: Welcome
AdminOnly(w http.ResponseWriter, r *http.Request) (err error) // MARKER: AdminOnly
ManagerOnly(w http.ResponseWriter, r *http.Request) (err error) // MARKER: ManagerOnly
}
ToDo is implemented by the service or mock. The intermediate delegates handling to this interface.