Documentation
¶
Index ¶
- Constants
- func RegisterServer(server HttpServer)
- func SaveStreamToFile(reader io.Reader, outFilePath string) error
- type CookieSameSite
- type HttpCookie
- type HttpCookieOptions
- type HttpHost
- func (m *HttpHost) CONNECT(path string, h HttpMiddleware)
- func (m *HttpHost) DELETE(path string, h HttpMiddleware)
- func (m *HttpHost) GET(path string, h HttpMiddleware)
- func (m *HttpHost) GetHostName() string
- func (m *HttpHost) GetServer() HttpServer
- func (m *HttpHost) GetUrlResolver(methodCode HttpMethod) *UrlResolver
- func (m *HttpHost) HEAD(path string, h HttpMiddleware)
- func (m *HttpHost) Impl() HttpHostImpl
- func (m *HttpHost) OPTIONS(path string, h HttpMiddleware)
- func (m *HttpHost) OnError(req HttpRequest, err error)
- func (m *HttpHost) OnNotFound(req HttpRequest)
- func (m *HttpHost) PATCH(path string, h HttpMiddleware)
- func (m *HttpHost) POST(path string, h HttpMiddleware)
- func (m *HttpHost) PUT(path string, h HttpMiddleware)
- func (m *HttpHost) Reset()
- func (m *HttpHost) TRACE(path string, h HttpMiddleware)
- func (m *HttpHost) VERB(verb string, path string, h HttpMiddleware)
- type HttpHostImpl
- type HttpHostInfos
- type HttpMethod
- type HttpMiddleware
- type HttpMultiPartForm
- type HttpRequest
- type HttpServer
- type HttpServerStartParams
- type UrlResolver
- type UrlResolverResult
- type UrlResolverTreeItem
- type ValueSet
Constants ¶
View Source
const CookieSameSiteDefaultMode = CookieSameSite(1)
View Source
const CookieSameSiteDisabled = CookieSameSite(0)
View Source
const CookieSameSiteLaxMode = CookieSameSite(2)
View Source
const CookieSameSiteNoneMode = CookieSameSite(4)
View Source
const CookieSameSiteStrictMode = CookieSameSite(3)
View Source
const HttpReturnCode200Ok int = 200
View Source
const HttpReturnCode404NotFound int = 404
View Source
const HttpReturnCode500ServerError int = 500
Variables ¶
This section is empty.
Functions ¶
func RegisterServer ¶
func RegisterServer(server HttpServer)
RegisterServer allows registering a server instance in a map allowing to known listened port <--> server.
Types ¶
type CookieSameSite ¶
type CookieSameSite int
type HttpCookie ¶
type HttpCookieOptions ¶
type HttpHost ¶
type HttpHost struct {
// contains filtered or unexported fields
}
func NewHttpHost ¶
func NewHttpHost(hostName string, server HttpServer, impl HttpHostImpl) *HttpHost
func (*HttpHost) CONNECT ¶
func (m *HttpHost) CONNECT(path string, h HttpMiddleware)
func (*HttpHost) DELETE ¶
func (m *HttpHost) DELETE(path string, h HttpMiddleware)
func (*HttpHost) GET ¶
func (m *HttpHost) GET(path string, h HttpMiddleware)
func (*HttpHost) GetHostName ¶
func (*HttpHost) GetServer ¶
func (m *HttpHost) GetServer() HttpServer
func (*HttpHost) GetUrlResolver ¶
func (m *HttpHost) GetUrlResolver(methodCode HttpMethod) *UrlResolver
func (*HttpHost) HEAD ¶
func (m *HttpHost) HEAD(path string, h HttpMiddleware)
func (*HttpHost) Impl ¶
func (m *HttpHost) Impl() HttpHostImpl
func (*HttpHost) OPTIONS ¶
func (m *HttpHost) OPTIONS(path string, h HttpMiddleware)
func (*HttpHost) OnError ¶
func (m *HttpHost) OnError(req HttpRequest, err error)
func (*HttpHost) OnNotFound ¶
func (m *HttpHost) OnNotFound(req HttpRequest)
func (*HttpHost) PATCH ¶
func (m *HttpHost) PATCH(path string, h HttpMiddleware)
func (*HttpHost) POST ¶
func (m *HttpHost) POST(path string, h HttpMiddleware)
func (*HttpHost) PUT ¶
func (m *HttpHost) PUT(path string, h HttpMiddleware)
func (*HttpHost) TRACE ¶
func (m *HttpHost) TRACE(path string, h HttpMiddleware)
type HttpHostImpl ¶
type HttpHostImpl interface {
Reset(host *HttpHost)
}
type HttpHostInfos ¶
HttpHostInfos allows designing a host by his hostname and port.
type HttpMethod ¶
type HttpMethod int
const ( HttpMethodGET HttpMethod = iota HttpMethodPOST HttpMethodHEAD HttpMethodPUT HttpMethodDELETE HttpMethodCONNECT HttpMethodOPTIONS HttpMethodTRACE HttpMethodPATCH )
func MethodNameToMethodCode ¶
func MethodNameToMethodCode(method string) HttpMethod
type HttpMiddleware ¶
type HttpMiddleware func(call HttpRequest) error
HttpMiddleware is a function the system can call when a request occurs.
type HttpMultiPartForm ¶
type HttpMultiPartForm struct {
Values map[string][]string
Files map[string][]*multipart.FileHeader
}
type HttpRequest ¶
type HttpRequest interface {
GetMethodName() string
GetMethodCode() HttpMethod
GetContentLength() int
IsBodySend() bool
GetContentType() string
SetContentType(contentType string)
SetHeader(key, value string)
GetHeaders() map[string]string
ReturnString(status int, text string)
GetQueryArgs() ValueSet
GetPostArgs() ValueSet
IsMultipartForm() bool
GetMultipartForm() (*HttpMultiPartForm, error)
GetCookie(name string) (map[string]any, error)
GetCookies() (map[string]map[string]any, error)
SetCookie(key string, value string, cookie HttpCookieOptions) error
Path() string
URI() string
UserAgent() string
RemoteIP() string
GetHost() *HttpHost
Return500ErrorPage(err error)
Return404UnknownPage()
SetUnlockMutex(mutex *sync.Mutex)
UnlockMutex()
MustStop() bool
StopRequest()
GetWildcards() []string
GetRemainingSegment() []string
}
type HttpServer ¶
type HttpServer interface {
GetPort() int
IsStarted() bool
Shutdown()
StartServer() error
GetHost(hostName string) *HttpHost
SetStartServerParams(params HttpServerStartParams)
}
func GetHttpServer ¶
func GetHttpServer(port int) HttpServer
GetHttpServer allows to get the server instance listening to the given port. Return nil if no one.
type HttpServerStartParams ¶
type HttpServerStartParams struct {
}
HttpServerStartParams will contains information on how to configure the server instance to create.
type UrlResolver ¶
type UrlResolver struct {
// contains filtered or unexported fields
}
UrlResolver allows to bind an listener to an url part. It's a router.
func NewUrlResolver ¶
func NewUrlResolver() *UrlResolver
func (*UrlResolver) AppendMiddleware ¶
func (m *UrlResolver) AppendMiddleware(path string, handler any, tag any)
AppendMiddleware add a handler which is always executed before the other handlers.
func (*UrlResolver) DumpTree ¶
func (m *UrlResolver) DumpTree() []UrlResolverTreeItem
func (*UrlResolver) Find ¶
func (m *UrlResolver) Find(path string) UrlResolverResult
func (*UrlResolver) Print ¶
func (m *UrlResolver) Print()
type UrlResolverResult ¶
type UrlResolverResult struct {
Segments []string
RemainingSegments []string
Target any
Middlewares []any
// contains filtered or unexported fields
}
func (*UrlResolverResult) GetWildcards ¶
func (m *UrlResolverResult) GetWildcards() []string
type UrlResolverTreeItem ¶
Click to show internal directories.
Click to hide internal directories.