Documentation
¶
Overview ¶
Package login implements the login.example microservice.
The Login microservice demonstrates usage of authentication and authorization.
Index ¶
- Constants
- type Actor
- type Mock
- type Service
- func (svc *Service) AdminOnly(w http.ResponseWriter, r *http.Request) (err error)
- func (svc *Service) Init(initializer func(svc *Service)) *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)
Constants ¶
const Hostname = "login.example"
Hostname is the default hostname of the microservice: login.example.
const SourceCodeSHA256 = "c013a7622db07668083117aa9b1a1c63144b7701253ecd646bf22b56d3fb7792"
const Timestamp = "2025-11-29T02:31:02.051216Z"
const Version = 80
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 Mock ¶
type Mock = intermediate.Mock
Mock is a mockable version of the login.example microservice, allowing functions, event sinks and web handlers to be mocked.
type Service ¶
type Service struct {
*intermediate.Intermediate // DO NOT REMOVE
}
Service implements the login.example microservice.
The Login microservice demonstrates usage of authentication and authorization.
func (*Service) Init ¶
Init enables a single-statement pattern for initializing the microservice.
svc.Init(func(svc Service) {
svc.SetGreeting("Hello")
})
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.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package intermediate serves as the foundation of the login.example microservice.
|
Package intermediate serves as the foundation of the login.example microservice. |
|
Package loginapi implements the public API of the login.example microservice, including clients and data structures.
|
Package loginapi implements the public API of the login.example microservice, including clients and data structures. |