server

package
v0.1.777 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDefaultHTTP2Server added in v0.1.559

func NewDefaultHTTP2Server() *http2.Server

NewDefaultHTTP2Server returns a properly tuned *http2.Server for Cloud Run or any long-lived, streaming-compatible HTTP/2 use.

Types

type Client

type Client interface {
	contract.ServerOperator
}

func NewClient

func NewClient(ctx context.Context, d Dependencies, opts ClientOptions) (Client, error)

type ClientOption

type ClientOption func(*ClientOptions)

func WithAddr

func WithAddr(x string) ClientOption

func WithAllowedOrigins

func WithAllowedOrigins(x []string) ClientOption

func WithH2

func WithH2(x *H2Conf) ClientOption

func WithIdleTimeout

func WithIdleTimeout(x time.Duration) ClientOption

func WithNotFoundHandler

func WithNotFoundHandler(x contract.HandlerFunc) ClientOption

func WithReadTimeout

func WithReadTimeout(x time.Duration) ClientOption

func WithShutdownTimeout

func WithShutdownTimeout(x time.Duration) ClientOption

func WithWriteTimeout

func WithWriteTimeout(x time.Duration) ClientOption

type ClientOptions

type ClientOptions struct {
	Addr            string
	AllowedOrigins  []string
	H2              *H2Conf
	IdleTimeout     time.Duration
	ReadTimeout     time.Duration
	WriteTimeout    time.Duration
	ShutdownTimeout time.Duration
	NotFoundHandler contract.HandlerFunc
}

func ApplyClientOptions

func ApplyClientOptions(opts *ClientOptions, modifiers ...ClientOption) ClientOptions

type DefaultTool added in v0.1.24

type DefaultTool struct {
	T *contract.Tool[Client]
}

func NewTool

func NewTool(c Client, opts contract.ToolOptions[Client]) *DefaultTool

func (*DefaultTool) GetBoundOn added in v0.1.246

func (d *DefaultTool) GetBoundOn(ctx context.Context) (string, error)

GetBoundOn returns the address the server is bound to.

func (*DefaultTool) GetIdleTimeout added in v0.1.246

func (d *DefaultTool) GetIdleTimeout(ctx context.Context) (time.Duration, error)

GetIdleTimeout returns the server's idle timeout.

func (*DefaultTool) GetReadTimeout added in v0.1.246

func (d *DefaultTool) GetReadTimeout(ctx context.Context) (time.Duration, error)

GetReadTimeout returns the server's read timeout.

func (*DefaultTool) GetUseH2C added in v0.1.246

func (d *DefaultTool) GetUseH2C(ctx context.Context) (bool, error)

GetUseH2C reports whether H2C (HTTP/2 without TLS) is enabled.

func (*DefaultTool) GetUseHTTP2 added in v0.1.246

func (d *DefaultTool) GetUseHTTP2(ctx context.Context) (bool, error)

GetUseHTTP2 reports whether HTTP/2 is enabled.

func (*DefaultTool) GetWriteTimeout added in v0.1.246

func (d *DefaultTool) GetWriteTimeout(ctx context.Context) (time.Duration, error)

GetWriteTimeout returns the server's write timeout.

func (*DefaultTool) Run added in v0.1.24

func (d *DefaultTool) Run(ctx context.Context) error

Run starts the server and blocks until shutdown or error.

func (*DefaultTool) ServeHTTP added in v0.1.24

func (d *DefaultTool) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is the entrypoint for all HTTP traffic.

func (*DefaultTool) Shutdown added in v0.1.24

func (d *DefaultTool) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the server.

func (*DefaultTool) WithNotFoundHandler added in v0.1.283

func (d *DefaultTool) WithNotFoundHandler(ctx context.Context, x contract.HandlerFunc) error

WithNotFoundHandler sets the not found handler.

type H2Conf

type H2Conf struct {
	H2c  bool
	FS   fs.ReadFileFS
	Cert string
	Key  string
}

H2Conf holds optional TLS or H2C configuration.

type KeyFn added in v0.1.198

type KeyFn func(ctx context.Context) (string, error)

type ParsePathFn

type ParsePathFn func(ctx context.Context, r *http.Request, reg *regexp.Regexp) (map[string]string, error)

type ParseQueryFn

type ParseQueryFn func(ctx context.Context, r *http.Request) (map[string][]string, error)

type Tool added in v0.1.245

type Tool interface {
	Client
}

Jump to

Keyboard shortcuts

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