Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- func (_c Client) AdminOnly(ctx context.Context, relativeURL string) (res *http.Response, err error)
- func (_c Client) ForHost(host string) Client
- func (_c Client) Login(ctx context.Context, method string, relativeURL string, body any) (res *http.Response, err error)
- func (_c Client) Logout(ctx context.Context, method string, relativeURL string, body any) (res *http.Response, err error)
- func (_c Client) ManagerOnly(ctx context.Context, relativeURL string) (res *http.Response, err error)
- func (_c Client) Welcome(ctx context.Context, method string, relativeURL string, body any) (res *http.Response, err error)
- func (_c Client) WithOptions(opts ...pub.Option) Client
- type MulticastClient
- func (_c MulticastClient) AdminOnly(ctx context.Context, relativeURL string) iter.Seq[*pub.Response]
- func (_c MulticastClient) ForHost(host string) MulticastClient
- func (_c MulticastClient) Login(ctx context.Context, method string, relativeURL string, body any) iter.Seq[*pub.Response]
- func (_c MulticastClient) Logout(ctx context.Context, method string, relativeURL string, body any) iter.Seq[*pub.Response]
- func (_c MulticastClient) ManagerOnly(ctx context.Context, relativeURL string) iter.Seq[*pub.Response]
- func (_c MulticastClient) Welcome(ctx context.Context, method string, relativeURL string, body any) iter.Seq[*pub.Response]
- func (_c MulticastClient) WithOptions(opts ...pub.Option) MulticastClient
Constants ¶
const Description = `The Login microservice demonstrates usage of authentication and authorization.`
Description is the human-readable summary of the microservice, surfaced in OpenAPI and discovery.
const Hostname = "login.example"
Hostname is the default hostname of the microservice.
const Name = "Login"
Name is the decorative PascalCase name of the microservice.
const Version = 93
Version is a generation counter bumped on each regeneration, not a semantic version.
Variables ¶
var AdminOnly = define.Web{ Host: Hostname, Method: "GET", Route: "/admin-only", RequiredClaims: "roles.a", }
AdminOnly is only accessible by admins.
var Login = define.Web{ Host: Hostname, Method: "ANY", Route: "/login", }
Login renders a simple login screen that authenticates a user. Known users are hardcoded as "admin", "manager" and "user". The password is "password".
var Logout = define.Web{ Host: Hostname, Method: "ANY", Route: "/logout", }
Logout renders a page that logs out the user.
var ManagerOnly = define.Web{ Host: Hostname, Method: "GET", Route: "/manager-only", RequiredClaims: "roles.m", }
ManagerOnly is only accessible by managers.
var Welcome = define.Web{ Host: Hostname, Method: "ANY", Route: "/welcome", RequiredClaims: "roles.a || roles.m || roles.u", }
Welcome renders a page that is shown to the user after a successful login. Rendering is adjusted based on the user's roles.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a lightweight proxy for making unicast calls to the microservice.
func (Client) ForHost ¶
ForHost returns a copy of the client with a different hostname to be applied to requests.
func (Client) Login ¶
func (_c Client) Login(ctx context.Context, method string, relativeURL string, body any) (res *http.Response, err error)
Login renders a simple login screen that authenticates a user. Known users are hardcoded as "admin", "manager" and "user". The password is "password".
func (Client) Logout ¶
func (_c Client) Logout(ctx context.Context, method string, relativeURL string, body any) (res *http.Response, err error)
Logout renders a page that logs out the user.
func (Client) ManagerOnly ¶
func (_c Client) ManagerOnly(ctx context.Context, relativeURL string) (res *http.Response, err error)
ManagerOnly is only accessible by managers.
type MulticastClient ¶
type MulticastClient struct {
// contains filtered or unexported fields
}
MulticastClient is a lightweight proxy for making multicast calls to the microservice.
func NewMulticastClient ¶
func NewMulticastClient(caller service.Publisher) MulticastClient
NewMulticastClient creates a new multicast client proxy to the microservice.
func (MulticastClient) AdminOnly ¶
func (_c MulticastClient) AdminOnly(ctx context.Context, relativeURL string) iter.Seq[*pub.Response]
AdminOnly is only accessible by admins.
func (MulticastClient) ForHost ¶
func (_c MulticastClient) ForHost(host string) MulticastClient
ForHost returns a copy of the client with a different hostname to be applied to requests.
func (MulticastClient) Login ¶
func (_c MulticastClient) Login(ctx context.Context, method string, relativeURL string, body any) iter.Seq[*pub.Response]
Login renders a simple login screen that authenticates a user. Known users are hardcoded as "admin", "manager" and "user". The password is "password".
func (MulticastClient) Logout ¶
func (_c MulticastClient) Logout(ctx context.Context, method string, relativeURL string, body any) iter.Seq[*pub.Response]
Logout renders a page that logs out the user.
func (MulticastClient) ManagerOnly ¶
func (_c MulticastClient) ManagerOnly(ctx context.Context, relativeURL string) iter.Seq[*pub.Response]
ManagerOnly is only accessible by managers.
func (MulticastClient) Welcome ¶
func (_c MulticastClient) Welcome(ctx context.Context, method string, relativeURL string, body any) iter.Seq[*pub.Response]
Welcome renders a page that is shown to the user after a successful login. Rendering is adjusted based on the user's roles.
func (MulticastClient) WithOptions ¶
func (_c MulticastClient) WithOptions(opts ...pub.Option) MulticastClient
WithOptions returns a copy of the client with options to be applied to requests.