internal

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(r *http.Request, v ...any)

Error logs the given v along with r in error log.

func Errorf

func Errorf(r *http.Request, format string, v ...any)

Errorf logs the given v with format along with r in error log.

func Info

func Info(r *http.Request, v ...any)

Info logs the given v along with r in access log.

func Infof

func Infof(r *http.Request, format string, v ...any)

Infof logs the given v with format along with r in access log.

func StartHttp

func StartHttp(host string, port int, handler http.Handler, opts ...StartOption) error

StartHttp starts a http server.

func StartHttps

func StartHttps(host string, port int, certFile, keyFile string, handler http.Handler,
	opts ...StartOption) error

StartHttps starts a https server.

func WithLogCollector

func WithLogCollector(ctx context.Context, lc *LogCollector) context.Context

WithLogCollector returns a new context with LogCollector.

Types

type LogCollector

type LogCollector struct {
	Messages []string
	// contains filtered or unexported fields
}

LogCollector is used to collect logs.

func LogCollectorFromContext

func LogCollectorFromContext(ctx context.Context) *LogCollector

LogCollectorFromContext returns LogCollector from ctx.

func (*LogCollector) Append

func (lc *LogCollector) Append(msg string)

Append appends msg into log context.

func (*LogCollector) Flush

func (lc *LogCollector) Flush() string

Flush flushes collected logs.

type StartOption

type StartOption func(svr *http.Server)

StartOption defines the method to customize http.Server.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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