Documentation
¶
Overview ¶
http/http_helpers.go
Index ¶
- func Catch(err error, message core.HttpMessage)
- func GetErrorHandler(errName string) core.ErrorHandler
- func NewMiddlewareConfigBuilder() core.IMiddlewareConfigBuilder
- func SetErrorHandlers(handlers map[string]core.ErrorHandler)
- type CookieManager
- type HTTPRequestScope
- func (s *HTTPRequestScope) Body() (body []byte, err error)
- func (s *HTTPRequestScope) BodyReader() io.ReadCloser
- func (s *HTTPRequestScope) FormFile(key string) (core.IFile, error)
- func (s *HTTPRequestScope) GetFiles(key string) ([]core.IFile, error)
- func (s *HTTPRequestScope) GetMultipartFormValues() *multipart.Form
- func (s *HTTPRequestScope) Header() http.Header
- func (s *HTTPRequestScope) IP() string
- func (s *HTTPRequestScope) Locale() string
- func (s *HTTPRequestScope) PathParam(name string) string
- func (s *HTTPRequestScope) Query() core.QueryParams
- func (s *HTTPRequestScope) QueryParam(key string) string
- func (s *HTTPRequestScope) QueryParams(key string) []string
- func (s *HTTPRequestScope) QueryParamsMap(key string) []map[string]string
- func (s *HTTPRequestScope) RawQuery() string
- func (s *HTTPRequestScope) RawRequest() *http.Request
- type HTTPResponseScope
- func (s *HTTPResponseScope) Bytes(b []byte, c int)
- func (s *HTTPResponseScope) Header() http.Header
- func (s *HTTPResponseScope) JSON(v interface{}, c int)
- func (s *HTTPResponseScope) RawWriter() http.ResponseWriter
- func (s *HTTPResponseScope) Redirect(u string, c int)
- func (s *HTTPResponseScope) SetHeader(k, v string)
- func (s *HTTPResponseScope) Text(b string, c int)
- type HTTPSessionScope
- type HTTPViewScope
- type InputResolver
- type JsonParser
- type Message
- func (s *Message) Close() error
- func (m *Message) Context() context.Context
- func (m *Message) Cookie() core.ICookieManager
- func (m *Message) Init()
- func (m *Message) RedirectWithFlash(urlStr string, code int, data map[string]interface{})
- func (m *Message) Request() core.IRequestScope
- func (m *Message) Response() core.IResponseScope
- func (m *Message) Session() core.ISessionScope
- func (m *Message) View() core.IViewScope
- type MiddlewareConfig
- type MiddlewareConfigBuilder
- func (thiz *MiddlewareConfigBuilder) AsFilter() core.IMiddlewareConfigBuilder
- func (thiz *MiddlewareConfigBuilder) Build() core.IMiddlewareConfig
- func (thiz *MiddlewareConfigBuilder) WithExcludePatterns(patterns []string) core.IMiddlewareConfigBuilder
- func (thiz *MiddlewareConfigBuilder) WithMiddleware(mw core.IMiddleware) core.IMiddlewareConfigBuilder
- func (thiz *MiddlewareConfigBuilder) WithPattern(pattern string) core.IMiddlewareConfigBuilder
- type MultipartParser
- type QueryParser
- type ResponseWriterWrapper
- type WebContext
- func (wc *WebContext) AddController(c core.IController)
- func (wc *WebContext) AddMiddleware(reg core.IMiddlewareConfig)
- func (wc *WebContext) GetControllers() []core.IController
- func (wc *WebContext) GetHomeUrl() string
- func (wc *WebContext) GetMiddlewares() []core.IMiddlewareConfig
- func (wc *WebContext) GetNewInputResolver() core.InputResolverFactory
- func (wc *WebContext) GetNewMessage() core.MessageFactory
- func (wc *WebContext) GetNotFound() core.HandlerFunc
- func (wc *WebContext) SetHomeUrl(url string)
- func (wc *WebContext) SetNewInputResolver(f core.InputResolverFactory)
- func (wc *WebContext) SetNewMessage(f core.MessageFactory)
- func (wc *WebContext) SetNotFound(h core.HandlerFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Catch ¶
func Catch(err error, message core.HttpMessage)
func GetErrorHandler ¶
func GetErrorHandler(errName string) core.ErrorHandler
func NewMiddlewareConfigBuilder ¶
func NewMiddlewareConfigBuilder() core.IMiddlewareConfigBuilder
func SetErrorHandlers ¶
func SetErrorHandlers(handlers map[string]core.ErrorHandler)
Types ¶
type CookieManager ¶
type CookieManager struct {
// contains filtered or unexported fields
}
func NewCookieManager ¶
func NewCookieManager(writer http.ResponseWriter, r *http.Request) *CookieManager
func (*CookieManager) GetCookies ¶
func (thiz *CookieManager) GetCookies() []*http.Cookie
func (*CookieManager) SetCookie ¶
func (thiz *CookieManager) SetCookie(cookie *http.Cookie)
type HTTPRequestScope ¶
HTTPRequestScope wraps *http.Request and adds query-parsing & secure file upload.
func NewHTTPRequestScope ¶
func NewHTTPRequestScope(r *http.Request) *HTTPRequestScope
NewHTTPRequestScope reads file-size and mimes from viper (in MB / slice).
func (*HTTPRequestScope) Body ¶
func (s *HTTPRequestScope) Body() (body []byte, err error)
func (*HTTPRequestScope) BodyReader ¶
func (s *HTTPRequestScope) BodyReader() io.ReadCloser
BodyReader returns the raw Body. Caller must Close().
func (*HTTPRequestScope) FormFile ¶
func (s *HTTPRequestScope) FormFile(key string) (core.IFile, error)
FormFile enforces size and mime checks, and sanitizes filename.
func (*HTTPRequestScope) GetFiles ¶
func (s *HTTPRequestScope) GetFiles(key string) ([]core.IFile, error)
GetFiles same checks for multiple.
func (*HTTPRequestScope) GetMultipartFormValues ¶
func (s *HTTPRequestScope) GetMultipartFormValues() *multipart.Form
func (*HTTPRequestScope) Header ¶
func (s *HTTPRequestScope) Header() http.Header
Header gives direct access.
func (*HTTPRequestScope) Locale ¶
func (s *HTTPRequestScope) Locale() string
func (*HTTPRequestScope) PathParam ¶
func (s *HTTPRequestScope) PathParam(name string) string
PathParam returns chi URL-param.
func (*HTTPRequestScope) Query ¶
func (s *HTTPRequestScope) Query() core.QueryParams
func (*HTTPRequestScope) QueryParam ¶
func (s *HTTPRequestScope) QueryParam(key string) string
QueryParam returns single value after decoder parsing.
func (*HTTPRequestScope) QueryParams ¶
func (s *HTTPRequestScope) QueryParams(key string) []string
QueryParams returns []string for key.
func (*HTTPRequestScope) QueryParamsMap ¶
func (s *HTTPRequestScope) QueryParamsMap(key string) []map[string]string
QueryParamsMap returns []map[string]string for key.
func (*HTTPRequestScope) RawQuery ¶
func (s *HTTPRequestScope) RawQuery() string
RawQuery returns r.URL.RawQuery.
func (*HTTPRequestScope) RawRequest ¶
func (s *HTTPRequestScope) RawRequest() *http.Request
type HTTPResponseScope ¶
type HTTPResponseScope struct {
W http.ResponseWriter
// contains filtered or unexported fields
}
func NewHTTPResponseScope ¶
func NewHTTPResponseScope(w http.ResponseWriter, r *http.Request) *HTTPResponseScope
func (*HTTPResponseScope) Bytes ¶
func (s *HTTPResponseScope) Bytes(b []byte, c int)
func (*HTTPResponseScope) Header ¶
func (s *HTTPResponseScope) Header() http.Header
func (*HTTPResponseScope) JSON ¶
func (s *HTTPResponseScope) JSON(v interface{}, c int)
func (*HTTPResponseScope) RawWriter ¶
func (s *HTTPResponseScope) RawWriter() http.ResponseWriter
func (*HTTPResponseScope) Redirect ¶
func (s *HTTPResponseScope) Redirect(u string, c int)
func (*HTTPResponseScope) SetHeader ¶
func (s *HTTPResponseScope) SetHeader(k, v string)
func (*HTTPResponseScope) Text ¶
func (s *HTTPResponseScope) Text(b string, c int)
type HTTPSessionScope ¶
type HTTPSessionScope struct {
Auth core.IAuthContext
Storage core.ISessionStorage
Ctx context.Context
// contains filtered or unexported fields
}
func NewHTTPSessionScope ¶
func NewHTTPSessionScope(ctx context.Context, authContext core.IAuthContext, sessionStorage core.ISessionStorage) *HTTPSessionScope
func (*HTTPSessionScope) ClearExpiredFlash ¶
func (s *HTTPSessionScope) ClearExpiredFlash()
func (*HTTPSessionScope) Get ¶
func (s *HTTPSessionScope) Get() core.ISession
func (*HTTPSessionScope) Set ¶
func (s *HTTPSessionScope) Set(session core.ISession)
type HTTPViewScope ¶
type HTTPViewScope struct {
Engine core.IEngineRenderer
Ctx context.Context
Writer http.ResponseWriter
}
func NewHTTPViewScope ¶
func NewHTTPViewScope(ctx context.Context, writer http.ResponseWriter, engineRenderer core.IEngineRenderer) *HTTPViewScope
type InputResolver ¶
type InputResolver struct {
ReflectedHandler reflect.Value
Message core.HttpMessage
Validator core.IValidator `container:"inject"`
}
type JsonParser ¶
type JsonParser struct {
// contains filtered or unexported fields
}
JsonParser handles custom JSON unmarshaling with support for special types and behaviors such as custom field binding methods and domain object loading.
func (*JsonParser) Parse ¶
func (p *JsonParser) Parse(dest interface{}) error
type Message ¶
type Message struct {
Req core.IRequestScope
Res core.IResponseScope
Ses core.ISessionScope
Vw core.IViewScope
CookieManager core.ICookieManager
// contains filtered or unexported fields
}
Message is a facade for controllers and dispatcher.
func (*Message) Cookie ¶
func (m *Message) Cookie() core.ICookieManager
func (*Message) RedirectWithFlash ¶
RedirectWithFlash saves flash data and redirects.
func (*Message) Request ¶
func (m *Message) Request() core.IRequestScope
func (*Message) Response ¶
func (m *Message) Response() core.IResponseScope
func (*Message) Session ¶
func (m *Message) Session() core.ISessionScope
func (*Message) View ¶
func (m *Message) View() core.IViewScope
type MiddlewareConfig ¶
type MiddlewareConfig struct {
// contains filtered or unexported fields
}
func (*MiddlewareConfig) GetExcludePatterns ¶
func (thiz *MiddlewareConfig) GetExcludePatterns() []string
func (*MiddlewareConfig) GetMiddleware ¶
func (thiz *MiddlewareConfig) GetMiddleware() core.IMiddleware
func (*MiddlewareConfig) GetPattern ¶
func (thiz *MiddlewareConfig) GetPattern() string
func (*MiddlewareConfig) IsFilter ¶
func (thiz *MiddlewareConfig) IsFilter() bool
type MiddlewareConfigBuilder ¶
type MiddlewareConfigBuilder struct {
// contains filtered or unexported fields
}
func (*MiddlewareConfigBuilder) AsFilter ¶
func (thiz *MiddlewareConfigBuilder) AsFilter() core.IMiddlewareConfigBuilder
func (*MiddlewareConfigBuilder) Build ¶
func (thiz *MiddlewareConfigBuilder) Build() core.IMiddlewareConfig
func (*MiddlewareConfigBuilder) WithExcludePatterns ¶
func (thiz *MiddlewareConfigBuilder) WithExcludePatterns(patterns []string) core.IMiddlewareConfigBuilder
func (*MiddlewareConfigBuilder) WithMiddleware ¶
func (thiz *MiddlewareConfigBuilder) WithMiddleware(mw core.IMiddleware) core.IMiddlewareConfigBuilder
func (*MiddlewareConfigBuilder) WithPattern ¶
func (thiz *MiddlewareConfigBuilder) WithPattern(pattern string) core.IMiddlewareConfigBuilder
type MultipartParser ¶
type MultipartParser struct {
// contains filtered or unexported fields
}
MultipartParser handles parsing of multipart form data into Go structures
func (*MultipartParser) Parse ¶
func (p *MultipartParser) Parse(arg interface{}) error
Parse parses multipart form data into the provided structure It handles both form values and file uploads
type QueryParser ¶
type QueryParser struct {
// contains filtered or unexported fields
}
func (*QueryParser) Parse ¶
func (p *QueryParser) Parse(arg interface{}) error
type ResponseWriterWrapper ¶
type ResponseWriterWrapper struct {
http.Flusher
http.Hijacker
io.ReaderFrom
http.ResponseWriter
io.StringWriter
io.Writer
StatusCode int
Body io.ReadCloser
Headers http.Header
}
func (*ResponseWriterWrapper) Header ¶
func (thiz *ResponseWriterWrapper) Header() http.Header
func (*ResponseWriterWrapper) Write ¶
func (thiz *ResponseWriterWrapper) Write(b []byte) (int, error)
func (*ResponseWriterWrapper) WriteHeader ¶
func (thiz *ResponseWriterWrapper) WriteHeader(code int)
type WebContext ¶
type WebContext struct {
// contains filtered or unexported fields
}
func (*WebContext) AddController ¶
func (wc *WebContext) AddController(c core.IController)
func (*WebContext) AddMiddleware ¶
func (wc *WebContext) AddMiddleware(reg core.IMiddlewareConfig)
func (*WebContext) GetControllers ¶
func (wc *WebContext) GetControllers() []core.IController
func (*WebContext) GetHomeUrl ¶
func (wc *WebContext) GetHomeUrl() string
func (*WebContext) GetMiddlewares ¶
func (wc *WebContext) GetMiddlewares() []core.IMiddlewareConfig
func (*WebContext) GetNewInputResolver ¶
func (wc *WebContext) GetNewInputResolver() core.InputResolverFactory
func (*WebContext) GetNewMessage ¶
func (wc *WebContext) GetNewMessage() core.MessageFactory
func (*WebContext) GetNotFound ¶
func (wc *WebContext) GetNotFound() core.HandlerFunc
func (*WebContext) SetHomeUrl ¶
func (wc *WebContext) SetHomeUrl(url string)
func (*WebContext) SetNewInputResolver ¶
func (wc *WebContext) SetNewInputResolver(f core.InputResolverFactory)
func (*WebContext) SetNewMessage ¶
func (wc *WebContext) SetNewMessage(f core.MessageFactory)
func (*WebContext) SetNotFound ¶
func (wc *WebContext) SetNotFound(h core.HandlerFunc)