intermediate

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package intermediate serves as the foundation of the http.ingress.core microservice.

The HTTP ingress microservice relays incoming HTTP requests to the NATS bus.

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.

func (*Intermediate) AllowedOrigins

func (svc *Intermediate) AllowedOrigins() (origins string)

AllowedOrigins is a comma-separated list of CORS origins to allow requests from. The * origin can be used to allow CORS request from all origins.

func (*Intermediate) BlockedPaths

func (svc *Intermediate) BlockedPaths() (blockedPaths string)

A newline-separated list of paths or extensions to block with a 404. Paths should not include any arguments and are matched exactly. Extensions are specified with "*.ext" and are matched against the extension of the path only.

func (*Intermediate) PortMappings

func (svc *Intermediate) PortMappings() (mappings string)

PortMappings is a comma-separated list of mappings in the form x:y->z where x is the inbound HTTP port, y is the requested NATS port, and z is the port to serve. An HTTP request https://ingresshost:x/servicehost:y/path is mapped to internal NATS request https://servicehost:z/path . Both x and y can be * to indicate all ports. Setting z to * indicates to serve the requested port y without change. Specific rules take precedence over * rules. The default mapping grants access to all internal ports via HTTP port 8080 but restricts HTTP ports 443 and 80 to only internal port 443.

func (*Intermediate) Ports

func (svc *Intermediate) Ports() (port string)

Ports is a comma-separated list of HTTP ports on which to listen for requests.

func (*Intermediate) ReadHeaderTimeout

func (svc *Intermediate) ReadHeaderTimeout() (timeout time.Duration)

ReadHeaderTimeout specifies the timeout for fully reading the header of a request.

func (*Intermediate) ReadTimeout

func (svc *Intermediate) ReadTimeout() (timeout time.Duration)

ReadTimeout specifies the timeout for fully reading a request.

func (*Intermediate) RequestMemoryLimit

func (svc *Intermediate) RequestMemoryLimit() (megaBytes int)

RequestMemoryLimit is the memory capacity used to hold pending requests, in megabytes.

func (*Intermediate) ServerLanguages

func (svc *Intermediate) ServerLanguages() (languages string)

ServerLanguages is a comma-separated list of languages that the server supports. This list is matched against the Accept-Language header of the request.

func (*Intermediate) SetAllowedOrigins

func (svc *Intermediate) SetAllowedOrigins(origins string) error

SetAllowedOrigins sets the value of the configuration property.

AllowedOrigins is a comma-separated list of CORS origins to allow requests from. The * origin can be used to allow CORS request from all origins.

func (*Intermediate) SetBlockedPaths

func (svc *Intermediate) SetBlockedPaths(blockedPaths string) error

SetBlockedPaths sets the value of the configuration property.

A newline-separated list of paths or extensions to block with a 404. Paths should not include any arguments and are matched exactly. Extensions are specified with "*.ext" and are matched against the extension of the path only.

func (*Intermediate) SetPortMappings

func (svc *Intermediate) SetPortMappings(mappings string) error

SetPortMappings sets the value of the configuration property.

PortMappings is a comma-separated list of mappings in the form x:y->z where x is the inbound HTTP port, y is the requested NATS port, and z is the port to serve. An HTTP request https://ingresshost:x/servicehost:y/path is mapped to internal NATS request https://servicehost:z/path . Both x and y can be * to indicate all ports. Setting z to * indicates to serve the requested port y without change. Specific rules take precedence over * rules. The default mapping grants access to all internal ports via HTTP port 8080 but restricts HTTP ports 443 and 80 to only internal port 443.

func (*Intermediate) SetPorts

func (svc *Intermediate) SetPorts(port string) error

SetPorts sets the value of the configuration property.

Ports is a comma-separated list of HTTP ports on which to listen for requests.

func (*Intermediate) SetReadHeaderTimeout

func (svc *Intermediate) SetReadHeaderTimeout(timeout time.Duration) error

SetReadHeaderTimeout sets the value of the configuration property.

ReadHeaderTimeout specifies the timeout for fully reading the header of a request.

func (*Intermediate) SetReadTimeout

func (svc *Intermediate) SetReadTimeout(timeout time.Duration) error

SetReadTimeout sets the value of the configuration property.

ReadTimeout specifies the timeout for fully reading a request.

func (*Intermediate) SetRequestMemoryLimit

func (svc *Intermediate) SetRequestMemoryLimit(megaBytes int) error

SetRequestMemoryLimit sets the value of the configuration property.

RequestMemoryLimit is the memory capacity used to hold pending requests, in megabytes.

func (*Intermediate) SetServerLanguages

func (svc *Intermediate) SetServerLanguages(languages string) error

SetServerLanguages sets the value of the configuration property.

ServerLanguages is a comma-separated list of languages that the server supports. This list is matched against the Accept-Language header of the request.

func (*Intermediate) SetTimeBudget

func (svc *Intermediate) SetTimeBudget(budget time.Duration) error

SetTimeBudget sets the value of the configuration property.

TimeBudget specifies the timeout for handling a request, after it has been read. A value of 0 or less indicates no time budget.

func (*Intermediate) SetWriteTimeout

func (svc *Intermediate) SetWriteTimeout(timeout time.Duration) error

SetWriteTimeout sets the value of the configuration property.

WriteTimeout specifies the timeout for fully writing the response to a request.

func (*Intermediate) TimeBudget

func (svc *Intermediate) TimeBudget() (budget time.Duration)

TimeBudget specifies the timeout for handling a request, after it has been read. A value of 0 or less indicates no time budget.

func (*Intermediate) WriteTimeout

func (svc *Intermediate) WriteTimeout() (timeout time.Duration)

WriteTimeout specifies the timeout for fully writing the response to a request.

type Mock

type Mock struct {
	*Intermediate
}

Mock is a mockable version of the http.ingress.core 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) OnChangedAllowedOrigins

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

OnChangedAllowedOrigins is a no op.

func (*Mock) OnChangedBlockedPaths

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

OnChangedBlockedPaths is a no op.

func (*Mock) OnChangedPortMappings

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

OnChangedPortMappings is a no op.

func (*Mock) OnChangedPorts

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

OnChangedPorts is a no op.

func (*Mock) OnChangedReadHeaderTimeout

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

OnChangedReadHeaderTimeout is a no op.

func (*Mock) OnChangedReadTimeout

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

OnChangedReadTimeout is a no op.

func (*Mock) OnChangedServerLanguages

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

OnChangedServerLanguages is a no op.

func (*Mock) OnChangedWriteTimeout

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

OnChangedWriteTimeout is a no op.

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.

type ToDo

type ToDo interface {
	OnStartup(ctx context.Context) (err error)
	OnShutdown(ctx context.Context) (err error)
	OnChangedPorts(ctx context.Context) (err error)
	OnChangedAllowedOrigins(ctx context.Context) (err error)
	OnChangedPortMappings(ctx context.Context) (err error)
	OnChangedReadTimeout(ctx context.Context) (err error)
	OnChangedWriteTimeout(ctx context.Context) (err error)
	OnChangedReadHeaderTimeout(ctx context.Context) (err error)
	OnChangedServerLanguages(ctx context.Context) (err error)
	OnChangedBlockedPaths(ctx context.Context) (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