http

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

http/http_helpers.go

Index

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) GetCookie

func (thiz *CookieManager) GetCookie(key string) *http.Cookie

func (*CookieManager) GetCookies

func (thiz *CookieManager) GetCookies() []*http.Cookie

func (*CookieManager) SetCookie

func (thiz *CookieManager) SetCookie(cookie *http.Cookie)

type HTTPRequestScope

type HTTPRequestScope struct {
	R *http.Request
	// contains filtered or unexported fields
}

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) IP

func (s *HTTPRequestScope) IP() string

IP resolves real client IP.

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

func (*HTTPViewScope) Render

func (s *HTTPViewScope) Render(tpl string, data map[string]any)

type InputResolver

type InputResolver struct {
	ReflectedHandler reflect.Value
	Message          core.HttpMessage
	Validator        core.IValidator `container:"inject"`
}

func (*InputResolver) Resolve

func (thiz *InputResolver) Resolve() ([]reflect.Value, error)

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) Close

func (s *Message) Close() error

func (*Message) Context

func (m *Message) Context() context.Context

func (*Message) Cookie

func (m *Message) Cookie() core.ICookieManager

func (*Message) Init

func (m *Message) Init()

func (*Message) RedirectWithFlash

func (m *Message) RedirectWithFlash(urlStr string, code int, data map[string]interface{})

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 (*MiddlewareConfigBuilder) Build

func (*MiddlewareConfigBuilder) WithExcludePatterns

func (thiz *MiddlewareConfigBuilder) WithExcludePatterns(patterns []string) core.IMiddlewareConfigBuilder

func (*MiddlewareConfigBuilder) WithMiddleware

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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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