Documentation ¶
Index ¶
- Constants
- Variables
- func AddLogFilterForRequest(exp string, replace string) error
- func AddValueToRequestContext(r *http.Request, key any, value any) (newR *http.Request)
- func CloneURLvalues(src url.Values) (dst url.Values)
- func CodeName(code int) string
- func ConcatLogFilterForRequest(f *misc.Replace)
- func ContentHeader(contentType string) (string, error)
- func Error(id uint64, answerSent bool, w http.ResponseWriter, r *http.Request, ...)
- func GetIdentityFromRequestContext(r *http.Request) (identity *auth.Identity, err error)
- func GetValueFromRequestContext(r *http.Request, key any) (value any)
- func JSONResultWithDataHash(data any, useHash bool, hash string, srcHeaders misc.StringMap) (result []byte, code int, headers misc.StringMap, err error)
- func ReadData(header http.Header, body io.ReadCloser) (bodyBuf *bytes.Buffer, code int, err error)
- func ReadRequestBody(r *http.Request) (bodyBuf *bytes.Buffer, code int, err error)
- func Request(method string, uri string, timeout time.Duration, opts misc.StringMap, ...) (*bytes.Buffer, *http.Response, error)
- func RequestEx(method string, uri string, timeout time.Duration, opts url.Values, ...) (*bytes.Buffer, *http.Response, error)
- func ReturnRefresh(id uint64, w http.ResponseWriter, r *http.Request, httpCode int, ...)
- func SendJSON(w http.ResponseWriter, r *http.Request, statusCode int, data any)
- func SetLogFilterForRequest(f *misc.Replace)
- func SetMinSizeForGzip(size int)
- func UseGzip(r *http.Request, dataLen int, headers misc.StringMap) bool
- func WriteContentHeader(w http.ResponseWriter, contentType string) error
- func WriteReply(w http.ResponseWriter, r *http.Request, httpCode int, contentCode string, ...) (err error)
- type BlackHole
- type ContextKey
- type ErrorResponse
- type ExtraInfoFunc
- type ExtraRootItemFunc
- type HTTP
- func (h *HTTP) AddAuthEndpoint(endpoint string, permissions misc.BoolMap)
- func (h *HTTP) AddAuthHandler(ah auth.Handler) (err error)
- func (h *HTTP) AddEndpointsInfo(list misc.StringMap)
- func (h *HTTP) AddHandler(handler Handler, toHead bool)
- func (h *HTTP) AddHandlerEx(handler HandlerEx, toHead bool)
- func (h *HTTP) CancelPathReplacing(path string)
- func (h *HTTP) Close() error
- func (h *HTTP) Config() *config.Listener
- func (h *HTTP) DelEndpointsInfo(list misc.StringMap)
- func (h *HTTP) Embedded(id uint64, prefix string, path string, w http.ResponseWriter, r *http.Request) (processed bool)
- func (h *HTTP) EndpointDescription(name string) string
- func (h *HTTP) File(id uint64, prefix string, path string, w http.ResponseWriter, r *http.Request) (processed bool)
- func (h *HTTP) GetPrefix(path string, r *http.Request) (prefix string, newPath string)
- func (h *HTTP) GetPrefixFromHeader(r *http.Request) (prefix string)
- func (h *HTTP) IsPathReplaced(path string) bool
- func (h *HTTP) MenuHighlight() (open template.HTML, close template.HTML)
- func (h *HTTP) RemoveStdPath(path string)
- func (h *HTTP) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (h *HTTP) SetExtraInfoFunc(f ExtraInfoFunc)
- func (h *HTTP) SetName(name string, description string)
- func (h *HTTP) SetRootItemsFunc(f ExtraRootItemFunc)
- func (h *HTTP) SetStatusFunc(f StatusFunc, paramsInfo string)
- func (h *HTTP) Start() error
- func (h *HTTP) Stop() error
- type Handler
- type HandlerEx
- type InfoBlock
- type StatusFunc
Constants ¶
View Source
const ( RequestOptionGzip = ".gzip" RequestOptionSkipTLSVerification = ".skip-tls-verification" RequestOptionBasicAuthUser = ".user" RequestOptionBasicAuthPassword = ".password" )
options with names starting with "." are used as internal parameters and are not added to query parameters
View Source
const ( // ContentTypeHTML -- ContentTypeHTML = "html" // ContentTypeCSS -- ContentTypeCSS = "css" // ContentTypeText -- ContentTypeText = "text" // ContentTypeJSON -- ContentTypeJSON = "json" // ContentTypeIcon -- ContentTypeIcon = "ico" // ContentTypeForm -- ContentTypeForm = "form" // ContentTypeBin -- ContentTypeBin = "bin" // MethodCONNECT -- MethodCONNECT = "CONNECT" // MethodTRACE -- MethodTRACE = "TRACE" // MethodOPTIONS -- MethodOPTIONS = "OPTIONS" // MethodHEAD -- MethodHEAD = "HEAD" // MethodGET -- MethodGET = "GET" // MethodPOST -- MethodPOST = "POST" // MethodPUT -- MethodPUT = "PUT" // MethodPATCH -- MethodPATCH = "PATCH" // MethodDELETE -- MethodDELETE = "DELETE" HTTPheaderHash = "X-Hash" // data hash )
View Source
const (
CtxIdentity = ContextKey("identity")
)
Variables ¶
View Source
var ( // Log -- Log = log.NewFacility("stdhttp") StdMethods = []string{ MethodCONNECT, MethodTRACE, MethodOPTIONS, MethodHEAD, MethodGET, MethodPOST, MethodPUT, MethodPATCH, MethodDELETE, } )
Functions ¶
func AddLogFilterForRequest ¶ added in v0.1.8
AddLogFilterForRequest --
func AddValueToRequestContext ¶ added in v0.1.88
AddValueToRequestContext --
func ConcatLogFilterForRequest ¶ added in v0.1.76
ConcatLogFilterForRequest --
func Error ¶
func Error(id uint64, answerSent bool, w http.ResponseWriter, r *http.Request, httpCode int, message string, err error)
Error --
func GetIdentityFromRequestContext ¶ added in v0.1.88
func GetValueFromRequestContext ¶ added in v0.1.88
GetValueFromRequestContext --
func JSONResultWithDataHash ¶ added in v0.1.89
func JSONResultWithDataHash(data any, useHash bool, hash string, srcHeaders misc.StringMap) (result []byte, code int, headers misc.StringMap, err error)
JSONResultWithDataHash --
func ReadRequestBody ¶
ReadRequestBody --
func Request ¶
func Request(method string, uri string, timeout time.Duration, opts misc.StringMap, extraHeaders misc.StringMap, data []byte) (*bytes.Buffer, *http.Response, error)
Request --
func RequestEx ¶ added in v0.1.12
func RequestEx(method string, uri string, timeout time.Duration, opts url.Values, extraHeaders http.Header, data []byte) (*bytes.Buffer, *http.Response, error)
RequestEx --
func ReturnRefresh ¶
func ReturnRefresh(id uint64, w http.ResponseWriter, r *http.Request, httpCode int, forceTo string, data []byte, err error)
ReturnRefresh --
func SetLogFilterForRequest ¶ added in v0.1.8
SetLogFilterForRequest --
func WriteContentHeader ¶
func WriteContentHeader(w http.ResponseWriter, contentType string) error
WriteContentHeader --
Types ¶
type ErrorResponse ¶ added in v0.1.118
type ErrorResponse struct {
Message string `json:"error"`
}
type HTTP ¶
HTTP --
func NewListener ¶
NewListener --
func NewListenerEx ¶ added in v0.1.100
func (*HTTP) AddAuthEndpoint ¶ added in v0.1.67
AddAuthEndpoint --
func (*HTTP) AddAuthHandler ¶ added in v0.1.57
AddAuthHandler --
func (*HTTP) AddEndpointsInfo ¶
AddEndpointsInfo --
func (*HTTP) AddHandler ¶ added in v0.1.67
AddHandler --
func (*HTTP) AddHandlerEx ¶ added in v0.1.100
AddHandlerEx --
func (*HTTP) CancelPathReplacing ¶ added in v0.1.29
CancelPathReplacing --
func (*HTTP) DelEndpointsInfo ¶ added in v0.1.108
func (*HTTP) EndpointDescription ¶ added in v0.1.121
func (*HTTP) File ¶ added in v0.1.25
func (h *HTTP) File(id uint64, prefix string, path string, w http.ResponseWriter, r *http.Request) (processed bool)
File --
func (*HTTP) GetPrefixFromHeader ¶ added in v0.1.111
func (*HTTP) IsPathReplaced ¶ added in v0.1.29
IsPathReplaced --
func (*HTTP) MenuHighlight ¶
MenuHighlight --
func (*HTTP) RemoveStdPath ¶ added in v0.1.29
RemoveStdPath --
func (*HTTP) ServeHTTP ¶
func (h *HTTP) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP --
func (*HTTP) SetExtraInfoFunc ¶
func (h *HTTP) SetExtraInfoFunc(f ExtraInfoFunc)
SetExtraInfoFunc --
func (*HTTP) SetRootItemsFunc ¶
func (h *HTTP) SetRootItemsFunc(f ExtraRootItemFunc)
SetRootItemsFunc --
func (*HTTP) SetStatusFunc ¶ added in v0.1.47
func (h *HTTP) SetStatusFunc(f StatusFunc, paramsInfo string)
SetStatusFunc --
type Handler ¶
type Handler interface {
Handler(id uint64, prefix string, path string, w http.ResponseWriter, r *http.Request) (processed bool)
}
Handler --
type HandlerEx ¶ added in v0.1.100
type HandlerEx interface {
Handler(id uint64, prefix string, path string, w http.ResponseWriter, r *http.Request) (processed bool, basePath string)
}
HandlerEx --
type InfoBlock ¶ added in v0.1.121
type InfoBlock struct { Application *applicationBlock `json:"application" comment:"Application info"` Runtime *runtimeBlock `json:"runtime" comment:"Runtime info"` Endpoints map[string]*endpointInfo `json:"endpoints" comment:"Enpoints info"` LastLog []string `json:"lastLog" comment:"Last lines from the log"` Extra any `json:"extra" comment:"Application extra info"` }
type StatusFunc ¶ added in v0.1.47
StatusFunc --
Click to show internal directories.
Click to hide internal directories.