goweb

package module
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: BSD-2-Clause Imports: 18 Imported by: 0

README

goweb

Web server implementation

If you find this project useful or want to support the author, you can send tokens to any of these wallets
  • Bitcoin: bc1qgx5c3n7q26qv0tngculjz0g78u6mzavy2vg3tf
  • Ethereum: 0x62812cb089E0df31347ca32A1610019537bbFe0D
  • Dogecoin: DET7fbNzZftp4sGRrBehfVRoi97RiPKajV

Documentation

Index

Constants

View Source
const (
	CommandStart   = "start"
	CommandStop    = "stop"
	CommandRestart = "restart"
	CommandStatus  = "status"
	CommandWeb     = "web"
)

Variables

Functions

func DecomposeCommand added in v1.2.0

func DecomposeCommand(command *gocli.Command) (action string, arguments []gocli.Argument, e porterr.IError)

DecomposeCommand Parse gocli.Command

func NewMiddlewareCollection

func NewMiddlewareCollection(config Config, app gocli.Application, maxLogBodySize int64) *middlewareCollection

NewMiddlewareCollection New Middleware Collection Init Method

Types

type Application

type Application struct {
	// The console application base interface.
	// Required for start
	gocli.Application
	// contains filtered or unexported fields
}

Application Web Application struct

func NewApplication

func NewApplication(config Config, app gocli.Application, connState func(net.Conn, http.ConnState)) *Application

NewApplication Init Web Application

func (*Application) Listen

func (a *Application) Listen(routes http.Handler)

Listen Make server and listen

func (*Application) WebCommander added in v1.2.0

func (a *Application) WebCommander(command *gocli.Command)

WebCommander Web command processor

type BindingIdentifier

type BindingIdentifier interface{}

BindingIdentifier Identifier for bind with connection

type Config

type Config struct {
	// Web application port
	Port int
	// Web application server host
	Host string
	// Web application url. For logging
	Url string
	// Server timeouts
	Timeout struct {
		// Timeout read
		Read int
		// Timeout write
		Write int
		// Timeout idle
		Idle int
	}
	// Web debug flag
	Debug bool
	// TLS config
	Security TLSConfig
}

Config Web configuration

type ConnectionBindings

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

ConnectionBindings Bindings

func NewConnectionBindings

func NewConnectionBindings() *ConnectionBindings

NewConnectionBindings New bindings

func (*ConnectionBindings) Bind

Bind Associate connection with id

func (*ConnectionBindings) GetBindingId

GetBindingId Get participantId by connection id

func (*ConnectionBindings) GetBindingIdentifiers added in v1.2.2

func (cb *ConnectionBindings) GetBindingIdentifiers() []BindingIdentifier

GetBindingIdentifiers Get all bindings identifiers

func (*ConnectionBindings) GetConnectionId

GetConnectionId Get connection Id by id

func (*ConnectionBindings) UnBind

UnBind Unbind connection with id

type ConnectionEvent

type ConnectionEvent struct {
	// Name of the event
	Name ConnectionEventName
	// Mark when event happens
	Done chan struct{}
}

ConnectionEvent Events that can be

type ConnectionEventListeners

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

ConnectionEventListeners Listeners struct

func NewConnectionEventListeners

func NewConnectionEventListeners() *ConnectionEventListeners

NewConnectionEventListeners New Connection event listener

func (*ConnectionEventListeners) Dispatch

Dispatch event

func (*ConnectionEventListeners) Get

Get events

func (*ConnectionEventListeners) Register

func (cel *ConnectionEventListeners) Register(id ConnectionIdentifier, name ConnectionEventName) <-chan struct{}

Register connection listener

func (*ConnectionEventListeners) Unregister

Unregister connection event listener

func (*ConnectionEventListeners) UnregisterConnection

UnregisterConnection unregister connection listener

type ConnectionEventName

type ConnectionEventName string

ConnectionEventName Event Name

type ConnectionIdentifier

type ConnectionIdentifier string

ConnectionIdentifier Connection unique identifier

type Connections

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

Connections contains connection map

func NewConnections

func NewConnections() *Connections

NewConnections Init tcp connection pool

func (*Connections) Get

Get connection if exists

func (*Connections) GetIdentifiers added in v1.2.1

func (cs *Connections) GetIdentifiers() []ConnectionIdentifier

GetIdentifiers get all identifiers

func (*Connections) Len

func (cs *Connections) Len() int

Len connections len

func (*Connections) Set

Set connection

func (*Connections) Unset

Unset connection if exists

type TLSConfig added in v1.3.0

type TLSConfig struct {
	// Use http2 features
	HTTP2Enable bool `yaml:"http2Enable"`
	// TLS certificate path
	ServerCert string `yaml:"serverCert"`
	// TLS private key path
	ServerKey string `yaml:"serverKey"`
}

TLSConfig TLS configuration

func (*TLSConfig) IsTLS added in v1.3.0

func (t *TLSConfig) IsTLS() bool

IsTLS is TLS enabled

Jump to

Keyboard shortcuts

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