server

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandStartServer

func CommandStartServer()

func NewAdminHandler

func NewAdminHandler() *jsoffnet.Http1Handler

func StartHTTPServer

func StartHTTPServer(rootCtx context.Context, serverCfg *ServerConfig)

Types

type Acc

type Acc struct {
	Name   string
	Chain  nodemuxcore.ChainRef
	Config AccountConfig
}

func AccFromContext

func AccFromContext(ctx context.Context) *Acc

func NewAccFromConfig

func NewAccFromConfig(name string, cfg AccountConfig) *Acc

type AccHandler

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

func NewAccHandler

func NewAccHandler(rootCtx context.Context, next http.Handler) *AccHandler

func (*AccHandler) ServeHTTP

func (self *AccHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type AccountConfig

type AccountConfig struct {
	Username  string          `yaml:"username" json:"username"`
	Ratelimit RatelimitConfig `yaml:"ratelimit,omitempty" json:"ratelimit,omitempty"`
}

type AdminConfig

type AdminConfig struct {
	Auth *jsoffnet.AuthConfig `yaml:"auth,omitempty" json:"auth,omitempty"`
}

type EntrypointConfig

type EntrypointConfig struct {
	Account string
	Chain   string
	Bind    string
	Auth    *jsoffnet.AuthConfig `yaml:"auth,omitempty" json:"auth,omitempty"`
	TLS     *jsoffnet.TLSConfig  `yaml:"tls,omitempty" json:"tls,omitempty"`
}

type GraphQLRelayer

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

GraphQL Handler

func NewGraphQLRelayer

func NewGraphQLRelayer(rootCtx context.Context) *GraphQLRelayer

func (*GraphQLRelayer) ServeHTTP

func (self *GraphQLRelayer) ServeHTTP(w http.ResponseWriter, r *http.Request)

type JSONRPCRelayer

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

JSONRPC Handler

func NewJSONRPCRelayer

func NewJSONRPCRelayer(rootCtx context.Context) *JSONRPCRelayer

func (*JSONRPCRelayer) ServeHTTP

func (self *JSONRPCRelayer) ServeHTTP(w http.ResponseWriter, r *http.Request)

type JSONRPCWSRelayer

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

JSONRPC Handler

func NewJSONRPCWSRelayer

func NewJSONRPCWSRelayer(rootCtx context.Context) *JSONRPCWSRelayer

func (*JSONRPCWSRelayer) ServeHTTP

func (self *JSONRPCWSRelayer) ServeHTTP(w http.ResponseWriter, r *http.Request)

type MetricsConfig

type MetricsConfig struct {
	Bind string
	Auth *jsoffnet.AuthConfig `yaml:"auth,omitempty" json:"auth,omitempty"`
	TLS  *jsoffnet.TLSConfig  `yaml:"tls:omitempty" json:"tls:omitempty"`
}

type RESTRelayer

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

REST Handler

func NewRESTRelayer

func NewRESTRelayer(rootCtx context.Context) *RESTRelayer

func (*RESTRelayer) ServeHTTP

func (self *RESTRelayer) ServeHTTP(w http.ResponseWriter, r *http.Request)

type RatelimitCollector added in v0.1.8

type RatelimitCollector struct {
}

func NewRatelimitCollector added in v0.1.8

func NewRatelimitCollector() *RatelimitCollector

func (RatelimitCollector) Collect added in v0.1.8

func (self RatelimitCollector) Collect(ch chan<- prometheus.Metric)

func (RatelimitCollector) Describe added in v0.1.8

func (self RatelimitCollector) Describe(ch chan<- *prometheus.Desc)

type RatelimitConfig

type RatelimitConfig struct {
	// requests per IP per hour
	IP int `yaml:"ip" json:"ip"`
	// requests per user per hour
	User int `yaml:"user" json:"user"`
}

func (RatelimitConfig) IPLimit

func (cfg RatelimitConfig) IPLimit() int

func (RatelimitConfig) UserLimit

func (cfg RatelimitConfig) UserLimit() int

Ratelimit Config

type RatelimitHandler

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

handle ratelimit

func NewRatelimitHandler

func NewRatelimitHandler(rootCtx context.Context, next http.Handler) *RatelimitHandler

func (*RatelimitHandler) ServeHTTP

func (self *RatelimitHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ServerConfig

type ServerConfig struct {
	Bind        string                   `yaml:"version,omitempty" json:"version,omitempty"`
	TLS         *jsoffnet.TLSConfig      `yaml:"tls,omitempty" json:"tls,omitempty"`
	Admin       *AdminConfig             `yaml:"admin,omitempty" json:"admin,omitempty"`
	Metrics     *MetricsConfig           `yaml:"metrics,omitempty" json:"metrics,omitempty"`
	Auth        *jsoffnet.AuthConfig     `yaml:"auth,omitempty" json:"auth,omitempty"`
	Entrypoints []EntrypointConfig       `yaml:"entrypoints,omitempty" json:"entrypoints,omitempty"`
	Ratelimit   RatelimitConfig          `yaml:"ratelimit,omitempty" json:"ratelimit,omitempty"`
	Accounts    map[string]AccountConfig `yaml:"accounts,omitempty" json:"accounts,omitempty"`
}

func NewServerConfig

func NewServerConfig() *ServerConfig

func ServerConfigFromContext

func ServerConfigFromContext(ctx context.Context) *ServerConfig

func ServerConfigFromFile

func ServerConfigFromFile(yamlPath string) (*ServerConfig, error)

func (*ServerConfig) AddTo

func (cfg *ServerConfig) AddTo(ctx context.Context) context.Context

func (*ServerConfig) Load

func (cfg *ServerConfig) Load(configPath string) error

func (*ServerConfig) LoadJsondata added in v0.1.6

func (cfg *ServerConfig) LoadJsondata(yamlData []byte) error

func (*ServerConfig) LoadYamldata

func (cfg *ServerConfig) LoadYamldata(yamlData []byte) error

Jump to

Keyboard shortcuts

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