request

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func App added in v1.0.12

func App(r *http.Request) string

* * App * @param r *http.Request * @return string *

func Delete

func Delete(url string, header et.Json) (*Body, Status)

* * Delete * @param url string, header et.Json * @return *Body, Status *

func DeleteWithTls added in v0.1.19

func DeleteWithTls(url string, header et.Json, tlsConfig *tls.Config) (*Body, Status)

* * DeleteWithTls * @param url string, header et.Json, tlsConfig *tls.Config * @return *Body, Status *

func Device added in v1.0.12

func Device(r *http.Request) string

* * Device * @param r *http.Request * @return string *

func Duration added in v1.0.20

func Duration(r *http.Request) time.Duration

* * Duration * @param r *http.Request * @return time.Duration *

func Fetch added in v0.1.17

func Fetch(method, url string, header, body et.Json) (*Body, Status)

* * Fetch * @param method, url string, header, body et.Json * @return *Body, Status *

func Get

func Get(url string, header et.Json) (*Body, Status)

* * Get * @param url string, header et.Json * @return *Body, Status *

func GetBody added in v1.0.20

func GetBody(r *http.Request) (et.Json, error)

* * GetBody * @param r *http.Request * @return et.Json, error *

func GetStr added in v1.0.20

func GetStr(r *http.Request) (string, error)

* * GetStr * @param r *http.Request * @return et.Json, error *

func GetWithTls added in v0.1.19

func GetWithTls(url string, header et.Json, tlsConfig *tls.Config) (*Body, Status)

* * GetWithTls * @param url string, header et.Json, tlsConfig *tls.Config * @return *Body, Status *

func Http added in v0.1.19

func Http(method, url string, header, body et.Json, tlsConfig *tls.Config) (*Body, Status)

* * Http * @param method, url string, header, body et.Json * @return *Body, Status *

func NewTlsConfig added in v0.1.18

func NewTlsConfig(caFile, certFile, keyFile string) (*tls.Config, error)

* * NewTlsConfig * @param caPath, certPath, keyPath string * @return *tls.Config, error *

func Options

func Options(url string, header et.Json) (*Body, Status)

* * Options * @param url string, header et.Json * @return *Body, Status *

func OptionsWithTls added in v0.1.19

func OptionsWithTls(url string, header et.Json, tlsConfig *tls.Config) (*Body, Status)

* * OptionsWithTls * @param url string, header et.Json, tlsConfig *tls.Config * @return *Body, Status *

func Patch

func Patch(url string, header, body et.Json) (*Body, Status)

* * Patch * @param url string, header, body et.Json * @return *Body, Status *

func PatchWithTls added in v0.1.19

func PatchWithTls(url string, header, body et.Json, tlsConfig *tls.Config) (*Body, Status)

* * PatchWithCA * @param url string, header, body et.Json, tlsConfig *tls.Config * @return *Body, Status *

func Payload added in v1.0.12

func Payload(r *http.Request) et.Json

* * Payload * @param r *http.Request * @return et.Json *

func Post

func Post(url string, header, body et.Json) (*Body, Status)

* * Post * @param url string, header, body et.Json * @return *Body, Status *

func PostWithTls added in v0.1.19

func PostWithTls(url string, header, body et.Json, tlsConfig *tls.Config) (*Body, Status)

* * PostWithTls * @param url string, header, body et.Json, tlsConfig *tls.Config * @return *Body, Status *

func ProfileId added in v1.0.20

func ProfileId(r *http.Request) string

* * ProfileId * @param r *http.Request * @return string *

func Put

func Put(url string, header, body et.Json) (*Body, Status)

* * Put * @param url string, header, body et.Json * @return *Body, Status *

func PutWithTls added in v0.1.19

func PutWithTls(url string, header, body et.Json, tlsConfig *tls.Config) (*Body, Status)

* * PutWithTls * @param url string, header, body et.Json, tlsConfig *tls.Config * @return *Body, Status *

func ServiceId added in v1.0.12

func ServiceId(r *http.Request) string

* * ServiceId * @param r *http.Request * @return string *

func SetApp added in v1.0.20

func SetApp(ctx context.Context, app string) context.Context

* * SetApp * @param ctx context.Context, app string * @return context.Context *

func SetDevice added in v1.0.20

func SetDevice(ctx context.Context, device string) context.Context

* * SetDevice * @param ctx context.Context, device string * @return context.Context *

func SetDuration added in v1.0.20

func SetDuration(ctx context.Context, duration time.Duration) context.Context

* * SetDuration * @param ctx context.Context, duration time.Duration * @return context.Context *

func SetPayload added in v1.0.20

func SetPayload(ctx context.Context, payload et.Json) context.Context

* * SetPayload * @param ctx context.Context, payload et.Json * @return context.Context *

func SetProfileId added in v1.0.20

func SetProfileId(ctx context.Context, profileId string) context.Context

* * SetProfileId * @param ctx context.Context, profileId string * @return context.Context *

func SetServiceId added in v1.0.20

func SetServiceId(ctx context.Context, serviceId string) context.Context

* * SetServiceId * @param ctx context.Context, serviceId string * @return context.Context *

func SetTenantId added in v1.0.20

func SetTenantId(ctx context.Context, tenantId string) context.Context

* * SetTenantId * @param ctx context.Context, tenantId string * @return context.Context *

func SetUserId added in v1.0.21

func SetUserId(ctx context.Context, userId string) context.Context

* * SetUserId * @param ctx context.Context, userId string * @return context.Context *

func SetUsername added in v1.0.20

func SetUsername(ctx context.Context, username string) context.Context

* * SetUsername * @param ctx context.Context, username string * @return context.Context *

func TenantId added in v1.0.20

func TenantId(r *http.Request) string

* * TenantId * @param r *http.Request * @return string *

func UserId added in v1.0.21

func UserId(r *http.Request) string

* * UserId * @param r *http.Request * @return string *

func Username added in v1.0.12

func Username(r *http.Request) string

* * Username * @param r *http.Request * @return string *

Types

type Body

type Body struct {
	Data []byte
}

* * Body struct to convert the body response *

func ReadBody

func ReadBody(body io.ReadCloser) (*Body, error)

* * ReadBody reads the body response * @param body io.ReadCloser * @return *Body, error *

func (Body) ToArrayJson

func (b Body) ToArrayJson() ([]et.Json, error)

* * ToArrayJson returns a Json array object * @return []et.Json *

func (Body) ToBool

func (b Body) ToBool() (bool, error)

* * ToBool returns a boolean * @return bool *

func (Body) ToFloat

func (b Body) ToFloat() (float64, error)

* * ToFloat returns a float * @return float64 *

func (Body) ToInt

func (b Body) ToInt() (int, error)

* * ToInt returns an integer * @return int *

func (Body) ToInt64

func (b Body) ToInt64() (int64, error)

* * ToInt64 returns an integer * @return int64 *

func (Body) ToItem added in v1.0.11

func (b Body) ToItem() (et.Item, error)

* * ToItem returns an Item object * @return et.Item *

func (Body) ToItems added in v1.0.11

func (b Body) ToItems() (et.Items, error)

* * ToItems returns an Items object * @return et.Items *

func (Body) ToJson

func (b Body) ToJson() (et.Json, error)

* * ToJson returns a Json object * @return et.Json *

func (Body) ToString

func (b Body) ToString() string

* * ToString returns a string * @return string *

func (Body) ToTime

func (b Body) ToTime() (time.Time, error)

* * ToTime returns a time * @return time.Time *

type ContextKey added in v1.0.12

type ContextKey string
const (
	DurationKey  ContextKey = "duration"
	PayloadKey   ContextKey = "payload"
	ServiceIdKey ContextKey = "service_id"
	AppKey       ContextKey = "app"
	DeviceKey    ContextKey = "device"
	UserIdKey    ContextKey = "user_id"
	UsernameKey  ContextKey = "username"
	TenantIdKey  ContextKey = "tenant_id"
	ProfileIdKey ContextKey = "profile_id"
)

func (ContextKey) Duration added in v1.0.12

func (s ContextKey) Duration(ctx context.Context, def time.Duration) time.Duration

* * Duration * @param ctx context.Context, def time.Duration * @return time.Duration *

func (ContextKey) Json added in v1.0.12

func (s ContextKey) Json(ctx context.Context, def et.Json) et.Json

* * Json * @param ctx context.Context, def et.Json * @return et.Json *

func (ContextKey) String added in v1.0.12

func (s ContextKey) String(ctx context.Context, def string) string

* * String * @param ctx context.Context, def string * @return string *

type Status

type Status struct {
	Ok      bool   `json:"ok"`
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func (Status) ToJson

func (s Status) ToJson() et.Json

ToJson returns a Json object

func (Status) ToString

func (s Status) ToString() string

ToString returns a string

type Value added in v1.0.21

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

func Query added in v1.0.21

func Query(r *http.Request, key string) *Value

* * Query * @param r *http.Request, key string * @return *Value *

func URLParam added in v1.0.21

func URLParam(r *http.Request, key string) *Value

* * Param * @param r *http.Request, key string * @return *Value *

func (*Value) Array added in v1.0.21

func (s *Value) Array() []any

* * Array returns an array * @return []any *

func (*Value) ArrayFloat added in v1.0.21

func (s *Value) ArrayFloat() []float64

* * ArrayFloat returns an array of floats * @return []float64 *

func (*Value) ArrayInt added in v1.0.21

func (s *Value) ArrayInt() []int

* * ArrayInt returns an array of integers * @return []int *

func (*Value) ArrayJson added in v1.0.21

func (s *Value) ArrayJson() []et.Json

* * ArrayJson returns an array of et.Json * @return []et.Json *

func (*Value) ArrayString added in v1.0.21

func (s *Value) ArrayString() []string

* * ArrayString returns an array of strings * @return []string *

func (*Value) Bool added in v1.0.21

func (s *Value) Bool() bool

* * Bool returns a boolean * @return bool *

func (*Value) DateTime added in v1.0.21

func (s *Value) DateTime() time.Time

* * DateTime returns a time.Time * @return time.Time *

func (*Value) Float added in v1.0.21

func (s *Value) Float() float64

* * Float returns a float * @return float64 *

func (*Value) Int added in v1.0.21

func (s *Value) Int() int

* * Int returns an integer * @return int *

func (*Value) Object added in v1.0.21

func (s *Value) Object() et.Json

* * Object returns an et.Json * @return et.Json *

func (*Value) Str added in v1.0.21

func (s *Value) Str() string

* * Str returns a string * @return string *

Jump to

Keyboard shortcuts

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