http

package
v0.67.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: Apache-2.0 Imports: 16 Imported by: 21

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicAuth

func BasicAuth(username, passwd string) string

func CanonicalHost

func CanonicalHost(host string) (string, error)

canonicalHost strips port from host if present and returns the canonicalized host name.

func MakeHTTPHandlerFunc added in v0.67.0

func MakeHTTPHandlerFunc(handler APIHandler) http.HandlerFunc

MakeHTTPHandlerFunc turns a normal APIHandler into a http.HandlerFunc.

func NewRequestLogger added in v0.67.0

func NewRequestLogger(next http.Handler) http.Handler

func OkResponse

func OkResponse() *http.Response

func ParseBasicAuth

func ParseBasicAuth(auth string) (username, password string, ok bool)

func ProxyUnauthorizedResponse

func ProxyUnauthorizedResponse() *http.Response

Types

type APIHandler added in v0.67.0

type APIHandler func(ctx *Context) (any, error)

APIHandler is a handler function that returns a response object or an error.

type Context added in v0.67.0

type Context struct {
	Req  *http.Request
	Resp http.ResponseWriter
	// contains filtered or unexported fields
}

func NewContext added in v0.67.0

func NewContext(w http.ResponseWriter, r *http.Request) *Context

func (*Context) BindJSON added in v0.67.0

func (c *Context) BindJSON(obj any) error

func (*Context) Body added in v0.67.0

func (c *Context) Body() ([]byte, error)

func (*Context) Param added in v0.67.0

func (c *Context) Param(key string) string

func (*Context) Query added in v0.67.0

func (c *Context) Query(key string) string

type Error added in v0.67.0

type Error struct {
	Code int
	Err  error
}

func NewError added in v0.67.0

func NewError(code int, msg string) *Error

func (*Error) Error added in v0.67.0

func (e *Error) Error() string

type GeneralResponse added in v0.67.0

type GeneralResponse struct {
	Code int
	Msg  string
}

type RouterRegisterHelper

type RouterRegisterHelper struct {
	Router         *mux.Router
	AssetsFS       http.FileSystem
	AuthMiddleware mux.MiddlewareFunc
}

type Server

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

func NewServer

func NewServer(cfg v1.WebServerConfig) (*Server, error)

func (*Server) Address

func (s *Server) Address() string

func (*Server) Close

func (s *Server) Close() error

func (*Server) RouteRegister

func (s *Server) RouteRegister(register func(helper *RouterRegisterHelper))

func (*Server) Run

func (s *Server) Run() error

Jump to

Keyboard shortcuts

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