intermediate

package
v1.13.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package intermediate serves as the foundation of the login.example microservice.

The Login microservice demonstrates usage of authentication and authorization.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Intermediate

type Intermediate struct {
	*connector.Connector
	// contains filtered or unexported fields
}

Intermediate extends and customizes the generic base connector. Code generated microservices then extend the intermediate.

func NewService

func NewService(impl ToDo, version int) *Intermediate

NewService creates a new intermediate service.

type Mock

type Mock struct {
	*Intermediate
	// contains filtered or unexported fields
}

Mock is a mockable version of the login.example microservice, allowing functions, event sinks and web handlers to be mocked.

func NewMock

func NewMock() *Mock

NewMock creates a new mockable version of the microservice.

func (*Mock) AdminOnly

func (svc *Mock) AdminOnly(w http.ResponseWriter, r *http.Request) (err error)

AdminOnly runs the mock handler set by MockAdminOnly.

func (*Mock) Login

func (svc *Mock) Login(w http.ResponseWriter, r *http.Request) (err error)

Login runs the mock handler set by MockLogin.

func (*Mock) Logout

func (svc *Mock) Logout(w http.ResponseWriter, r *http.Request) (err error)

Logout runs the mock handler set by MockLogout.

func (*Mock) ManagerOnly

func (svc *Mock) ManagerOnly(w http.ResponseWriter, r *http.Request) (err error)

ManagerOnly runs the mock handler set by MockManagerOnly.

func (*Mock) MockAdminOnly

func (svc *Mock) MockAdminOnly(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock

MockAdminOnly sets up a mock handler for the AdminOnly endpoint.

func (*Mock) MockLogin

func (svc *Mock) MockLogin(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock

MockLogin sets up a mock handler for the Login endpoint.

func (*Mock) MockLogout

func (svc *Mock) MockLogout(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock

MockLogout sets up a mock handler for the Logout endpoint.

func (*Mock) MockManagerOnly

func (svc *Mock) MockManagerOnly(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock

MockManagerOnly sets up a mock handler for the ManagerOnly endpoint.

func (*Mock) MockWelcome

func (svc *Mock) MockWelcome(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock

MockWelcome sets up a mock handler for the Welcome endpoint.

func (*Mock) OnShutdown

func (svc *Mock) OnShutdown(ctx context.Context) (err error)

OnShutdown is a no op.

func (*Mock) OnStartup

func (svc *Mock) OnStartup(ctx context.Context) (err error)

OnStartup makes sure that the mock is not executed in a non-dev environment.

func (*Mock) Welcome

func (svc *Mock) Welcome(w http.ResponseWriter, r *http.Request) (err error)

Welcome runs the mock handler set by MockWelcome.

type ToDo

type ToDo interface {
	OnStartup(ctx context.Context) (err error)
	OnShutdown(ctx context.Context) (err error)
	Login(w http.ResponseWriter, r *http.Request) (err error)
	Logout(w http.ResponseWriter, r *http.Request) (err error)
	Welcome(w http.ResponseWriter, r *http.Request) (err error)
	AdminOnly(w http.ResponseWriter, r *http.Request) (err error)
	ManagerOnly(w http.ResponseWriter, r *http.Request) (err error)
}

ToDo defines the interface that the microservice must implement. The intermediate delegates handling to this interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL