server

package
v0.0.0-...-ca53d3e Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const BufferSize = 256 * 1024

BufferSize for coybuffer and websocket

Variables

This section is empty.

Functions

func Serve

func Serve(cfg *Config) (err error)

Types

type AuthConfig

type AuthConfig struct {
	User     string `yaml:"user"`
	Password string `yaml:"password"`
	Disabled bool   `yaml:"disabled"`
}

type Config

type Config struct {
	Addr string `yaml:"addr"`
	// NotFound is a file path to handles unhandled requests.
	NotFound string `yaml:"not_found"`
	// NotFoundDisabled if value is true, disables handle unhandled requests.
	NotFoundDisabled bool             `yaml:"not_found_disabled"`
	TCPSockets       TCPSocketsConfig `yaml:"tcp_sockets"`
	HTTP             struct {
		Routes map[string]*HttpConfig `yaml:"routes"`
	} `yaml:"http"`
}

type Handler

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

Handler handlers

func New

func New(
	handlers map[string]*TCPSocketConfig,
	handshakeTimeout time.Duration,
	dialTimeout time.Duration,
	writeTimeout time.Duration,
	enableCompression bool) *Handler

New new handler

func (*Handler) Proxy

func (h *Handler) Proxy() func(w http.ResponseWriter, r *http.Request)

Proxy proxy handler

type Handlers

type Handlers []http.Handler

func (Handlers) ServeHTTP

func (h Handlers) ServeHTTP(w http.ResponseWriter, r *http.Request)

type HttpConfig

type HttpConfig struct {
	Addr       string `yaml:"addr"`
	PathStrip  bool   `yaml:"path_strip"`
	PathHeader string `yaml:"path_header"`
	Dir        string `yaml:"dir"`
	// PathOverride overrides real file path.
	// This formatter haves 3 values:
	// 1. The requested path
	// 2. The DIR
	// 3. The route PATH
	PathOverride string `yaml:"path_override"`
	Disabled     bool   `yaml:"disabled"`
}

func (*HttpConfig) ToString

func (c *HttpConfig) ToString(dir string) string

type TCPSocketConfig

type TCPSocketConfig struct {
	Addr     string      `yaml:"addr"`
	Auth     *AuthConfig `yaml:"auth"`
	Disabled bool        `yaml:"disabled"`
}

func (*TCPSocketConfig) String

func (c *TCPSocketConfig) String() string

type TCPSocketsConfig

type TCPSocketsConfig struct {
	HandshakeTimeout   uint8                       `yaml:"handshake_timeout"`
	DialTimeout        uint8                       `yaml:"dial_timeout"`
	WriteTimeout       uint8                       `yaml:"write_timeout"`
	CompressionEnabled bool                        `yaml:"compression_enabled"`
	Auth               *AuthConfig                 `yaml:"auth"`
	Routes             map[string]*TCPSocketConfig `yaml:"routes"`
}

func (*TCPSocketsConfig) Defaults

func (c *TCPSocketsConfig) Defaults()

Jump to

Keyboard shortcuts

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