Documentation ¶
Index ¶
- Constants
- func AddLogOutput(w interface{}, key, value string) error
- func ENUM(values ...string) []string
- func ExecuteHandler(handlerOpts *handlerOptions, method string, expectedStatus int, ...)
- func ExecuteHandlerWithGzipRequestAndResponse(handlerOpts *handlerOptions, method string, expectedStatus int, ...)
- func ExecuteHandlerWithGzipResponse(handlerOpts *handlerOptions, method string, expectedStatus int, ...)
- func GetAsBool(key string, r *http.Request) *bool
- func GetAsBoolFromContext(key string, ctx context.Context) *bool
- func GetAsFloat32(key string, r *http.Request) *float32
- func GetAsFloat32FromContext(key string, ctx context.Context) *float32
- func GetAsFloat64(key string, r *http.Request) *float64
- func GetAsFloat64FromContext(key string, ctx context.Context) *float64
- func GetAsInt(key string, r *http.Request) *int
- func GetAsInt32(key string, r *http.Request) *int32
- func GetAsInt32FromContext(key string, ctx context.Context) *int32
- func GetAsInt64(key string, r *http.Request) *int64
- func GetAsInt64FromContext(key string, ctx context.Context) *int64
- func GetAsIntFromContext(key string, ctx context.Context) *int
- func GetAsString(key string, r *http.Request) *string
- func GetAsStringFromContext(key string, ctx context.Context) *string
- func GetAsTime(key string, r *http.Request) *time.Time
- func GetAsTimeFromContext(key string, ctx context.Context) *time.Time
- func GzipDecodeRequestBody(r *http.Request, model interface{}) error
- func GzipDecodeResponseBody(res *http.Response) ([]byte, error)
- func GzipEncodeRequestBody(body []byte) (io.ReadCloser, error)
- func NewHandler(opts ...HandlerOption) *handlerOptions
- func ReaderHelper(header http.Header, body io.ReadCloser) (io.Reader, error)
- func SelectMethod(u *UHTTP, chain Middleware, handlerOpts handlerOptions) http.HandlerFunc
- type HandlerFunc
- type HandlerFuncWithModel
- type HandlerOption
- func WithDelete(h HandlerFunc) HandlerOption
- func WithDeleteModel(m interface{}, h HandlerFuncWithModel) HandlerOption
- func WithGet(h HandlerFunc) HandlerOption
- func WithGetModel(m interface{}, h HandlerFuncWithModel) HandlerOption
- func WithMiddlewares(m []Middleware) HandlerOption
- func WithOptionsGet(r R) HandlerOption
- func WithPost(h HandlerFunc) HandlerOption
- func WithPostModel(m interface{}, h HandlerFuncWithModel) HandlerOption
- func WithPreProcess(p PreProcessFunc) HandlerOption
- func WithRequiredGet(r R) HandlerOption
- func WithTimeout(timeout time.Duration, timeoutMessage string) HandlerOption
- type LoggingResponseWriter
- type Middleware
- type PreProcessFunc
- type R
- type UHTTP
- func (u *UHTTP) AddContext(key string, value interface{}) error
- func (u *UHTTP) Handle(pattern string, opts *handlerOptions)
- func (u *UHTTP) ListenAndServe() error
- func (u *UHTTP) RegisterStaticFilesHandler(root string) error
- func (u *UHTTP) Render(w http.ResponseWriter, r *http.Request, model interface{})
- func (u *UHTTP) RenderError(w http.ResponseWriter, r *http.Request, err error)
- func (u *UHTTP) RenderErrorWithStatusCode(w http.ResponseWriter, r *http.Request, statusCode int, err error, logOut bool)
- func (u *UHTTP) RenderWithStatusCode(w http.ResponseWriter, r *http.Request, statusCode int, model interface{})
- type UhttpOption
- func WithAddress(address string) UhttpOption
- func WithCORS(cors string) UhttpOption
- func WithEncodingErrorLogLevel(level ulog.LogLevel) UhttpOption
- func WithGlobalMiddlewares(middlewares []Middleware) UhttpOption
- func WithGzipCompressionLevel(level int) UhttpOption
- func WithIdleTimeout(idleTimeout time.Duration) UhttpOption
- func WithLogger(logger ulog.ULogger) UhttpOption
- func WithParseModelErrorLogLevel(level ulog.LogLevel) UhttpOption
- func WithReadHeaderTimeout(readHeaderTimeout time.Duration) UhttpOption
- func WithReadTimeout(readTimeout time.Duration) UhttpOption
- func WithWriteTimeout(writeTimeout time.Duration) UhttpOption
Constants ¶
View Source
const ( CtxKeyPostModel string = "uhttp.postModel" CtxKeyGetParams string = "uhttp.getParams" )
Variables ¶
This section is empty.
Functions ¶
func AddLogOutput ¶ added in v1.0.41
func ExecuteHandler ¶ added in v1.0.41
func ExecuteHandlerWithGzipRequestAndResponse ¶ added in v1.0.42
func ExecuteHandlerWithGzipResponse ¶ added in v1.0.42
func GetAsBoolFromContext ¶ added in v1.0.41
func GetAsFloat32FromContext ¶ added in v1.0.41
func GetAsFloat64FromContext ¶ added in v1.0.41
func GetAsInt32FromContext ¶ added in v1.0.41
func GetAsInt64FromContext ¶ added in v1.0.41
func GetAsIntFromContext ¶ added in v1.0.41
func GetAsStringFromContext ¶ added in v1.0.41
func GetAsTimeFromContext ¶ added in v1.0.41
func GzipDecodeRequestBody ¶ added in v1.0.42
func GzipDecodeResponseBody ¶ added in v1.0.42
func GzipEncodeRequestBody ¶ added in v1.0.42
func GzipEncodeRequestBody(body []byte) (io.ReadCloser, error)
func NewHandler ¶ added in v1.0.50
func NewHandler(opts ...HandlerOption) *handlerOptions
func ReaderHelper ¶ added in v1.0.39
inspired by https://medium.com/axiomzenteam/put-your-http-requests-on-a-diet-3e1e52333014
func SelectMethod ¶
func SelectMethod(u *UHTTP, chain Middleware, handlerOpts handlerOptions) http.HandlerFunc
Types ¶
type HandlerFunc ¶ added in v1.0.50
type HandlerFuncWithModel ¶ added in v1.0.50
type HandlerOption ¶ added in v1.0.50
type HandlerOption interface {
// contains filtered or unexported methods
}
func WithDelete ¶ added in v1.0.50
func WithDelete(h HandlerFunc) HandlerOption
func WithDeleteModel ¶ added in v1.0.50
func WithDeleteModel(m interface{}, h HandlerFuncWithModel) HandlerOption
func WithGet ¶ added in v1.0.50
func WithGet(h HandlerFunc) HandlerOption
func WithGetModel ¶ added in v1.0.50
func WithGetModel(m interface{}, h HandlerFuncWithModel) HandlerOption
func WithMiddlewares ¶ added in v1.0.50
func WithMiddlewares(m []Middleware) HandlerOption
func WithOptionsGet ¶ added in v1.0.50
func WithOptionsGet(r R) HandlerOption
func WithPost ¶ added in v1.0.50
func WithPost(h HandlerFunc) HandlerOption
func WithPostModel ¶ added in v1.0.50
func WithPostModel(m interface{}, h HandlerFuncWithModel) HandlerOption
func WithPreProcess ¶ added in v1.0.50
func WithPreProcess(p PreProcessFunc) HandlerOption
func WithRequiredGet ¶ added in v1.0.50
func WithRequiredGet(r R) HandlerOption
func WithTimeout ¶ added in v1.0.50
func WithTimeout(timeout time.Duration, timeoutMessage string) HandlerOption
type LoggingResponseWriter ¶ added in v1.0.41
type LoggingResponseWriter struct { http.ResponseWriter // contains filtered or unexported fields }
func (*LoggingResponseWriter) AddLogOutput ¶ added in v1.0.41
func (lrw *LoggingResponseWriter) AddLogOutput(key, value string)
func (*LoggingResponseWriter) WriteHeader ¶ added in v1.0.41
func (lrw *LoggingResponseWriter) WriteHeader(code int)
type Middleware ¶
type Middleware func(next http.HandlerFunc) http.HandlerFunc
type PreProcessFunc ¶ added in v1.0.50
type UHTTP ¶ added in v1.0.50
type UHTTP struct {
// contains filtered or unexported fields
}
func NewUHTTP ¶ added in v1.0.50
func NewUHTTP(opts ...UhttpOption) *UHTTP
func (*UHTTP) AddContext ¶ added in v1.0.50
func (*UHTTP) ListenAndServe ¶ added in v1.0.50
func (*UHTTP) RegisterStaticFilesHandler ¶ added in v1.0.50
RegisterStaticFilesHandler which serves content from a directory and redirects all requests to non-existant files to index.html index.html must be present! - read all files from root directory - create cache for these files containing original, gzip, br - register handlers for main http-mux
func (*UHTTP) Render ¶ added in v1.0.50
func (u *UHTTP) Render(w http.ResponseWriter, r *http.Request, model interface{})
func (*UHTTP) RenderError ¶ added in v1.0.50
func (*UHTTP) RenderErrorWithStatusCode ¶ added in v1.0.50
func (*UHTTP) RenderWithStatusCode ¶ added in v1.0.50
type UhttpOption ¶ added in v1.0.50
type UhttpOption interface {
// contains filtered or unexported methods
}
func WithAddress ¶ added in v1.0.50
func WithAddress(address string) UhttpOption
func WithCORS ¶ added in v1.0.50
func WithCORS(cors string) UhttpOption
func WithEncodingErrorLogLevel ¶ added in v1.0.50
func WithEncodingErrorLogLevel(level ulog.LogLevel) UhttpOption
func WithGlobalMiddlewares ¶ added in v1.0.50
func WithGlobalMiddlewares(middlewares []Middleware) UhttpOption
func WithGzipCompressionLevel ¶ added in v1.0.50
func WithGzipCompressionLevel(level int) UhttpOption
func WithIdleTimeout ¶ added in v1.0.50
func WithIdleTimeout(idleTimeout time.Duration) UhttpOption
func WithLogger ¶ added in v1.0.50
func WithLogger(logger ulog.ULogger) UhttpOption
func WithParseModelErrorLogLevel ¶ added in v1.0.50
func WithParseModelErrorLogLevel(level ulog.LogLevel) UhttpOption
func WithReadHeaderTimeout ¶ added in v1.0.50
func WithReadHeaderTimeout(readHeaderTimeout time.Duration) UhttpOption
func WithReadTimeout ¶ added in v1.0.50
func WithReadTimeout(readTimeout time.Duration) UhttpOption
func WithWriteTimeout ¶ added in v1.0.50
func WithWriteTimeout(writeTimeout time.Duration) UhttpOption
Source Files ¶
- ContextKeys.go
- HandleStaticFiles.go
- Handler.go
- HandlerOptions.go
- HelpersGzip.go
- HelpersRendering.go
- Middleware.go
- MiddlewareAddLogging.go
- MiddlewareCors.go
- MiddlewareGetParams.go
- MiddlewareParseModel.go
- MiddlewarePreProcess.go
- MiddlewareSetJSONResponse.go
- MiddlewareWithContext.go
- Params.go
- ParamsHelpers.go
- ParamsParse.go
- SelectMethod.go
- TestingHelpers.go
- UHttp.go
- UhttpOptions.go
Click to show internal directories.
Click to hide internal directories.