http

package
v1.0.0-...-a0f063d Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Background

func Background() http.Context

func GinResponseMiddleware

func GinResponseMiddleware() httpcontract.Middleware

func NewGinContext

func NewGinContext(ctx *gin.Context) http.Context

func NewGinError

func NewGinError(instance *gin.Context) httpcontract.ResponseError

func NewGinRequest

func NewGinRequest(ctx *GinContext) httpcontract.Request

func NewGinSuccess

func NewGinSuccess(instance *gin.Context) httpcontract.ResponseSuccess

Types

type BodyWriter

type BodyWriter struct {
	gin.ResponseWriter
	// contains filtered or unexported fields
}

func (*BodyWriter) Body

func (w *BodyWriter) Body() *bytes.Buffer

func (*BodyWriter) Write

func (w *BodyWriter) Write(b []byte) (int, error)

func (*BodyWriter) WriteString

func (w *BodyWriter) WriteString(s string) (int, error)

type GinContext

type GinContext struct {
	// contains filtered or unexported fields
}

func (*GinContext) Context

func (c *GinContext) Context() context.Context

func (*GinContext) Deadline

func (c *GinContext) Deadline() (deadline time.Time, ok bool)

func (*GinContext) Done

func (c *GinContext) Done() <-chan struct{}

func (*GinContext) Err

func (c *GinContext) Err() error

func (*GinContext) Instance

func (c *GinContext) Instance() *gin.Context

func (*GinContext) Request

func (c *GinContext) Request() http.Request

func (*GinContext) Response

func (c *GinContext) Response() http.Response

func (*GinContext) Value

func (c *GinContext) Value(key any) any

func (*GinContext) WithValue

func (c *GinContext) WithValue(key string, value any)

type GinError

type GinError struct {
	// contains filtered or unexported fields
}

func (*GinError) Data

func (r *GinError) Data(contentType string, data []byte)

func (*GinError) Json

func (r *GinError) Json(code int, msg string, err error)

func (*GinError) String

func (r *GinError) String(format string, values ...any)

type GinRequest

type GinRequest struct {
	// contains filtered or unexported fields
}

func (*GinRequest) AbortWithStatus

func (r *GinRequest) AbortWithStatus(code int)

func (*GinRequest) AbortWithStatusJson

func (r *GinRequest) AbortWithStatusJson(code int, jsonObj any)

func (*GinRequest) Bind

func (r *GinRequest) Bind(obj any) error

func (*GinRequest) Cookie

func (r *GinRequest) Cookie(name string) (string, error)

func (*GinRequest) File

func (r *GinRequest) File(name string) (contractsfilesystem.File, error)

func (*GinRequest) Form

func (r *GinRequest) Form(key string, defaultValue ...string) string

func (*GinRequest) FullUrl

func (r *GinRequest) FullUrl() string

func (*GinRequest) Header

func (r *GinRequest) Header(key, defaultValue string) string

func (*GinRequest) Headers

func (r *GinRequest) Headers() http.Header

func (*GinRequest) Input

func (r *GinRequest) Input(key string, defaultValue ...string) string

func (*GinRequest) InputBool

func (r *GinRequest) InputBool(key string, defaultValue ...bool) bool

func (*GinRequest) InputInt

func (r *GinRequest) InputInt(key string, defaultValue ...int) int

func (*GinRequest) InputInt64

func (r *GinRequest) InputInt64(key string, defaultValue ...int64) int64

func (*GinRequest) Ip

func (r *GinRequest) Ip() string

func (*GinRequest) Json

func (r *GinRequest) Json(key string, defaultValue ...string) string

func (*GinRequest) Method

func (r *GinRequest) Method() string

func (*GinRequest) Next

func (r *GinRequest) Next()

func (*GinRequest) Origin

func (r *GinRequest) Origin() *http.Request

func (*GinRequest) Path

func (r *GinRequest) Path() string

func (*GinRequest) Query

func (r *GinRequest) Query(key string, defaultValue ...string) string

func (*GinRequest) QueryArray

func (r *GinRequest) QueryArray(key string) []string

func (*GinRequest) QueryBool

func (r *GinRequest) QueryBool(key string, defaultValue ...bool) bool

func (*GinRequest) QueryInt

func (r *GinRequest) QueryInt(key string, defaultValue ...int) int

func (*GinRequest) QueryInt64

func (r *GinRequest) QueryInt64(key string, defaultValue ...int64) int64

func (*GinRequest) QueryMap

func (r *GinRequest) QueryMap(key string) map[string]string

func (*GinRequest) Route

func (r *GinRequest) Route(key string) string

func (*GinRequest) RouteInt

func (r *GinRequest) RouteInt(key string) int

func (*GinRequest) RouteInt64

func (r *GinRequest) RouteInt64(key string) int64

func (*GinRequest) ShouldBind

func (r *GinRequest) ShouldBind(obj any) error

func (*GinRequest) ShouldBindJSON

func (r *GinRequest) ShouldBindJSON(obj any) error

func (*GinRequest) ShouldBindQuery

func (r *GinRequest) ShouldBindQuery(obj any) error

func (*GinRequest) ShouldBindUri

func (r *GinRequest) ShouldBindUri(obj any) error

func (*GinRequest) Url

func (r *GinRequest) Url() string

func (*GinRequest) Validate

func (r *GinRequest) Validate(rules map[string]string, options ...validatecontract.Option) (validatecontract.Validator, error)

func (*GinRequest) ValidateRequest

func (r *GinRequest) ValidateRequest(request httpcontract.FormRequest) (validatecontract.Errors, error)

type GinResponse

type GinResponse struct {
	// contains filtered or unexported fields
}

func NewGinResponse

func NewGinResponse(instance *gin.Context, origin httpcontract.ResponseOrigin) *GinResponse

func (*GinResponse) Data

func (r *GinResponse) Data(code int, contentType string, data []byte)

func (*GinResponse) Download

func (r *GinResponse) Download(filepath, filename string)

func (*GinResponse) Error

func (*GinResponse) File

func (r *GinResponse) File(filepath string)

func (*GinResponse) Header

func (r *GinResponse) Header(key, value string) httpcontract.Response

func (*GinResponse) Json

func (r *GinResponse) Json(code int, obj any)

func (*GinResponse) Origin

func (*GinResponse) Redirect

func (r *GinResponse) Redirect(code int, location string)

func (*GinResponse) SetCookie

func (r *GinResponse) SetCookie(name, value string, maxAge int, path, domain string, secure, httpOnly bool) httpcontract.Response

func (*GinResponse) String

func (r *GinResponse) String(code int, format string, values ...any)

func (*GinResponse) Success

func (*GinResponse) Writer

func (r *GinResponse) Writer() http.ResponseWriter

type GinSuccess

type GinSuccess struct {
	// contains filtered or unexported fields
}

func (*GinSuccess) Data

func (r *GinSuccess) Data(contentType string, data []byte)

func (*GinSuccess) Json

func (r *GinSuccess) Json(code int, msg string, data any)

func (*GinSuccess) String

func (r *GinSuccess) String(format string, values ...any)

type JsonRes

type JsonRes struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data any    `json:"data,omitempty"`
	Err  error  `json:"err,omitempty"`
}

type RateLimiter

type RateLimiter struct {
	// contains filtered or unexported fields
}

func NewRateLimiter

func NewRateLimiter() *RateLimiter

func (*RateLimiter) For

func (r *RateLimiter) For(name string, callback func(ctx http.Context) http.ILimit)

func (*RateLimiter) ForWithLimits

func (r *RateLimiter) ForWithLimits(name string, callback func(ctx http.Context) []http.ILimit)

func (*RateLimiter) Limiter

func (r *RateLimiter) Limiter(name string) func(ctx http.Context) []http.ILimit

type ServiceProvider

type ServiceProvider struct {
}

func (*ServiceProvider) Boot

func (database *ServiceProvider) Boot()

func (*ServiceProvider) Register

func (database *ServiceProvider) Register()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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