httpserver

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrValueRequired = errors.New("value required")
)

sentinel errors.

Functions

func Run

func Run() error

Run creates server instance and runs.

Types

type DebugServer

type DebugServer struct {
	HTTPServer                   *http.Server
	OutputWriter                 io.WriteCloser
	ListenAddr                   string
	HMACSecret                   string
	HMACHeaderName               string
	RawHTTPRequestFileSaveFormat string
	SecretToken                  string
	SecretTokenHeaderName        string
	ReadTimeout                  time.Duration
	ReadHeaderTimeout            time.Duration
	WriteTimeout                 time.Duration
	IdleTimeout                  time.Duration
	Color                        bool
	SaveRawHTTPRequest           bool
}

DebugServer represents server/handler args.

func New

func New(options ...Option) (*DebugServer, error)

New instantiates new http server instance.

func (*DebugServer) Start

func (s *DebugServer) Start() error

Start starts http server.

func (*DebugServer) Stop

func (s *DebugServer) Stop() error

Stop stops/shutdowns server.

type Option

type Option func(*DebugServer)

Option represents option function type.

func WithColor

func WithColor(b bool) Option

WithColor enables/disables colorful output.

func WithHMACHeaderName

func WithHMACHeaderName(s string) Option

WithHMACHeaderName sets HMAC header name value, will check this http header name in request header.

func WithHMACSecret

func WithHMACSecret(s string) Option

WithHMACSecret sets HMAC secret value.

func WithIdleTimeout

func WithIdleTimeout(dur time.Duration) Option

WithIdleTimeout sets http server's idle timeout.

func WithListenAddr

func WithListenAddr(addr string) Option

WithListenAddr sets listen addr.

func WithOutputWriter

func WithOutputWriter(s string) Option

WithOutputWriter sets output, where to write incoming webhook.

func WithRawHTTPRequestFileSaveFormat

func WithRawHTTPRequestFileSaveFormat(s string) Option

WithRawHTTPRequestFileSaveFormat set file save name format for raw http request.

func WithReadHeaderTimeout

func WithReadHeaderTimeout(dur time.Duration) Option

WithReadHeaderTimeout sets http server's read header timeout.

func WithReadTimeout

func WithReadTimeout(dur time.Duration) Option

WithReadTimeout sets http server's read timeout.

func WithSaveRawHTTPRequest

func WithSaveRawHTTPRequest(b bool) Option

WithSaveRawHTTPRequest enables/disables saving raw http request to disk.

func WithSecretToken added in v0.3.4

func WithSecretToken(s string) Option

WithSecretToken sets the secret value for secret token.

func WithSecretTokenHeaderName added in v0.3.4

func WithSecretTokenHeaderName(s string) Option

WithSecretTokenHeaderName sets secret token header name value, will check this http header name in request header.

func WithWriteTimeout

func WithWriteTimeout(dur time.Duration) Option

WithWriteTimeout sets http server's write timeout.

type VerboseServer

type VerboseServer interface {
	Start() error
	Stop() error
}

VerboseServer defines server behaviours.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳