httpserver

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: Apache-2.0 Imports: 27 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	PathFormatEcho       = 0
	PathFormatGoogleAPIs = 1
)

PathFormat values

Variables

This section is empty.

Functions

func Var

func Var(r *http.Request, key string) (string, bool)

Var return the specified variable value and exist from the current request, if any.

func Vars

func Vars(r *http.Request) map[string]string

Vars returns the route variables for the current request, if any.

func WithDescription

func WithDescription(desc string) interface{}

WithDescription for Route, description for this route

func WithFileSystem

func WithFileSystem(fs http.FileSystem) interface{}

WithFileSystem for Static And File

func WithFileSystemPath

func WithFileSystemPath(root string) interface{}

WithFileSystemPath for Static And File

func WithHide

func WithHide(hide bool) interface{}

WithHide for Route, not print this route

func WithInterceptor

func WithInterceptor(fn func(handler func(ctx Context) error) func(ctx Context) error) interface{}

WithInterceptor for Router

func WithPathFormat

func WithPathFormat(format PathFormat) interface{}

WithPathFormat .

Types

type Context

type Context interface {
	SetAttribute(key string, val interface{})
	Attribute(key string) interface{}
	Attributes() map[string]interface{}
	Request() *http.Request
	ResponseWriter() http.ResponseWriter
	Param(name string) string
	ParamNames() []string
}

Context handler context.

type Interceptor

type Interceptor func(handler func(ctx Context) error) func(ctx Context) error

Interceptor .

type LogConfig

type LogConfig struct {
	MaxBodySizeBytes int `file:"max_body_size_bytes" default:"1024" desc:"max body size in bytes"`
}

LogConfig .

type PathFormat

type PathFormat int32

PathFormat .

type Response

type Response interface {
	Status(Context) int
	ReadCloser(Context) io.ReadCloser
	Error(Context) error
}

Response .

type ResponseGetter

type ResponseGetter interface {
	Response(ctx Context) Response
}

ResponseGetter .

type Router

type Router interface {
	GET(path string, handler interface{}, options ...interface{})
	POST(path string, handler interface{}, options ...interface{})
	DELETE(path string, handler interface{}, options ...interface{})
	PUT(path string, handler interface{}, options ...interface{})
	PATCH(path string, handler interface{}, options ...interface{})
	HEAD(path string, handler interface{}, options ...interface{})
	CONNECT(path string, handler interface{}, options ...interface{})
	OPTIONS(path string, handler interface{}, options ...interface{})
	TRACE(path string, handler interface{}, options ...interface{})

	Any(path string, handler interface{}, options ...interface{})
	Static(prefix, root string, options ...interface{})
	File(path, filepath string, options ...interface{})

	Add(method, path string, handler interface{}, options ...interface{}) error
}

Router .

type RouterManager

type RouterManager interface {
	NewRouter(opts ...interface{}) RouterTx
	Reloadable() bool
	Started() <-chan struct{}
}

RouterManager .

type RouterTx

type RouterTx interface {
	Router
	Commit() error
	Rollback()
	Reloadable() bool
}

RouterTx .

Directories

Path Synopsis
examples
reloadable command
simple command

Jump to

Keyboard shortcuts

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