component

package
v1.0.27 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: MIT Imports: 23 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorization

type Authorization struct {
}

Authorization type

func (*Authorization) Authorize

func (a *Authorization) Authorize(endpoint model.Endpoint, httpMethod string) error

Authorize validates http method

type Balancer

type Balancer interface {
	AddTarget(*Target) bool
	RemoveTarget(string) bool
	Next() *Target
}

Balancer interface

func NewRandomBalancer

func NewRandomBalancer(targets []*Target) Balancer

NewRandomBalancer returns a random proxy balancer.

func NewRoundRobinBalancer

func NewRoundRobinBalancer(targets []*Target) Balancer

NewRoundRobinBalancer returns a round-robin proxy balancer.

type BasicAuthMethod

type BasicAuthMethod struct {
	Database *module.Database
}

BasicAuthMethod type

func (*BasicAuthMethod) Authenticate

func (b *BasicAuthMethod) Authenticate(endpoint model.Endpoint, authKey string) (model.BasicAuthData, error)

Authenticate validates auth headers

type CircuitBreaker

type CircuitBreaker struct {
	sync.RWMutex

	Driver  *service.Redis
	HashMap string
}

CircuitBreaker struct

func NewCircuitBreaker

func NewCircuitBreaker(redisDriver *service.Redis, hashMap string) *CircuitBreaker

NewCircuitBreaker gets a new instance

type CommonBalancer

type CommonBalancer struct {
	// contains filtered or unexported fields
}

CommonBalancer type

func (*CommonBalancer) AddTarget

func (b *CommonBalancer) AddTarget(target *Target) bool

AddTarget adds an upstream target to the list.

func (*CommonBalancer) RemoveTarget

func (b *CommonBalancer) RemoveTarget(url string) bool

RemoveTarget removes an upstream target from the list.

type Correlation

type Correlation struct {
}

Correlation struct

func NewCorrelation

func NewCorrelation() *Correlation

NewCorrelation creates a new instance

func (*Correlation) UUIDv4

func (c *Correlation) UUIDv4() string

UUIDv4 create a UUID version 4

type FileSystem

type FileSystem struct {
}

FileSystem struct

func NewFileSystem

func NewFileSystem() *FileSystem

NewFileSystem creates a new instance

func (*FileSystem) ClearDir

func (fs *FileSystem) ClearDir(dir string) error

ClearDir removes all files and sub dirs

func (*FileSystem) DeleteDir

func (fs *FileSystem) DeleteDir(dir string) error

DeleteDir deletes a dir

func (*FileSystem) DeleteFile

func (fs *FileSystem) DeleteFile(path string) error

DeleteFile deletes a file

func (*FileSystem) DirExists

func (fs *FileSystem) DirExists(path string) bool

DirExists reports whether the dir exists

func (*FileSystem) EnsureDir

func (fs *FileSystem) EnsureDir(dirName string, mode int) error

EnsureDir ensures that directory exists

func (*FileSystem) EnsureTrailingSlash

func (fs *FileSystem) EnsureTrailingSlash(dir string) string

EnsureTrailingSlash ensure there is a trailing slash

func (*FileSystem) FileExists

func (fs *FileSystem) FileExists(path string) bool

FileExists reports whether the named file exists

func (*FileSystem) GetHostname

func (fs *FileSystem) GetHostname() (string, error)

GetHostname gets the hostname

func (*FileSystem) PathExists

func (fs *FileSystem) PathExists(path string) bool

PathExists reports whether the path exists

func (*FileSystem) ReadFile

func (fs *FileSystem) ReadFile(path string) (string, error)

ReadFile get the file content

func (*FileSystem) RemoveStartingSlash

func (fs *FileSystem) RemoveStartingSlash(dir string) string

RemoveStartingSlash removes any starting slash

func (*FileSystem) RemoveTrailingSlash

func (fs *FileSystem) RemoveTrailingSlash(dir string) string

RemoveTrailingSlash removes any trailing slash

func (*FileSystem) StoreFile

func (fs *FileSystem) StoreFile(path, content string) error

StoreFile stores a file content

type Item

type Item struct {
	Context map[string]string
	Count   int
}

Item struct

type KeyBasedAuthMethod

type KeyBasedAuthMethod struct {
	Database *module.Database
}

KeyBasedAuthMethod type

func (*KeyBasedAuthMethod) Authenticate

func (k *KeyBasedAuthMethod) Authenticate(endpoint model.Endpoint, apiKey string) (model.KeyBasedAuthData, error)

Authenticate validates auth headers

type OAuthAuthMethod

type OAuthAuthMethod struct {
	Database *module.Database
}

OAuthAuthMethod type

func (*OAuthAuthMethod) Authenticate

func (o *OAuthAuthMethod) Authenticate(endpoint model.Endpoint, accessToken string) (model.OAuthData, error)

Authenticate validates auth headers

func (*OAuthAuthMethod) ValidateClientCredentials

func (o *OAuthAuthMethod) ValidateClientCredentials(authorizationToken string) (model.OAuthData, error)

ValidateClientCredentials validates client credentials

type Proxy

type Proxy struct {
	Name        string
	Upstream    string
	Meta        map[string]string
	RequestMeta []string
	RequestID   string

	HTTPRequest *http.Request
	HTTPWriter  http.ResponseWriter
}

Proxy type

func NewProxy

func NewProxy(
	httpRequest *http.Request,
	httpWriter http.ResponseWriter,
	name,
	upstream,
	meta string,
	requestMeta []string,
	requestID string,
) *Proxy

NewProxy creates a new instance

func (*Proxy) ConvertMetaData

func (p *Proxy) ConvertMetaData(meta string) map[string]string

ConvertMetaData converts meta data format into map meta in the form of key1:value1;key2:value2 ---> map{"key1": "value1", "key2": "value2"}

func (*Proxy) Redirect

func (p *Proxy) Redirect()

Redirect proxy the request to the remote service

type RandomBalancer

type RandomBalancer struct {
	*CommonBalancer
	// contains filtered or unexported fields
}

RandomBalancer implements a random load balancing technique.

func (*RandomBalancer) Next

func (b *RandomBalancer) Next() *Target

Next randomly returns an upstream target.

type RateLimiter

type RateLimiter struct {
	sync.RWMutex

	Driver  *service.Redis
	HashMap string
}

RateLimiter struct

func NewRateLimiter

func NewRateLimiter(redisDriver *service.Redis, hashMap string) *RateLimiter

NewRateLimiter gets a new instance

func (*RateLimiter) Inc

func (r *RateLimiter) Inc(key string, context map[string]string, rate string)

Inc increment the calls count

func (*RateLimiter) IsAllowed

func (r *RateLimiter) IsAllowed(key string, context map[string]string, rate string)

IsAllowed checks if http call is allowed

type Records

type Records struct {
	Items []Item
}

Records struct

func (*Records) ConvertToJSON

func (r *Records) ConvertToJSON() (string, error)

ConvertToJSON convert object to json

func (*Records) LoadFromJSON

func (r *Records) LoadFromJSON(data []byte) error

LoadFromJSON update object from json

type RoundRobinBalancer

type RoundRobinBalancer struct {
	*CommonBalancer
	// contains filtered or unexported fields
}

RoundRobinBalancer implements a round-robin load balancing technique.

func (*RoundRobinBalancer) Next

func (b *RoundRobinBalancer) Next() *Target

Next returns an upstream target using round-robin technique.

type Router

type Router struct {
}

Router type

func NewRouter

func NewRouter() *Router

NewRouter creates a new instance

func (*Router) BuildRemote

func (r *Router) BuildRemote(serviceURL, listenPath, path string) string

BuildRemote gets the final remote service URL to call

func (*Router) GetEndpoint

func (r *Router) GetEndpoint(endpoints []model.Endpoint, path string) (model.Endpoint, error)

GetEndpoint gets the endpoint

type Target

type Target struct {
	URL string
}

Target type

Jump to

Keyboard shortcuts

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