1
0
mirror of https://github.com/kataras/iris.git synced 2026-05-01 11:45:28 +00:00

update dependencies

This commit is contained in:
Gerasimos (Makis) Maropoulos
2025-08-15 23:29:20 +03:00
parent de4f462198
commit a8a3afea22
186 changed files with 694 additions and 689 deletions

View File

@@ -204,7 +204,7 @@ func RequestParam(key string, values ...string) RequestOption {
//
// Any HTTP returned error will be of type APIError
// or a timeout error if the given context was canceled.
func (c *Client) Do(ctx context.Context, method, urlpath string, payload interface{}, opts ...RequestOption) (*http.Response, error) {
func (c *Client) Do(ctx context.Context, method, urlpath string, payload any, opts ...RequestOption) (*http.Response, error) {
if ctx == nil {
ctx = context.Background()
}
@@ -309,7 +309,7 @@ const (
)
// JSON writes data as JSON to the server.
func (c *Client) JSON(ctx context.Context, method, urlpath string, payload interface{}, opts ...RequestOption) (*http.Response, error) {
func (c *Client) JSON(ctx context.Context, method, urlpath string, payload any, opts ...RequestOption) (*http.Response, error) {
opts = append(opts, RequestHeader(true, contentTypeKey, contentTypeJSON))
return c.Do(ctx, method, urlpath, payload, opts...)
}
@@ -397,7 +397,7 @@ func (c *Client) NewUploader() *Uploader {
// ReadJSON binds "dest" to the response's body.
// After this call, the response body reader is closed.
func (c *Client) ReadJSON(ctx context.Context, dest interface{}, method, urlpath string, payload interface{}, opts ...RequestOption) error {
func (c *Client) ReadJSON(ctx context.Context, dest any, method, urlpath string, payload any, opts ...RequestOption) error {
if payload != nil {
opts = append(opts, RequestHeader(true, contentTypeKey, contentTypeJSON))
}
@@ -426,7 +426,7 @@ func (c *Client) ReadJSON(ctx context.Context, dest interface{}, method, urlpath
// ReadPlain like ReadJSON but it accepts a pointer to a string or byte slice or integer
// and it reads the body as plain text.
func (c *Client) ReadPlain(ctx context.Context, dest interface{}, method, urlpath string, payload interface{}, opts ...RequestOption) error {
func (c *Client) ReadPlain(ctx context.Context, dest any, method, urlpath string, payload any, opts ...RequestOption) error {
resp, err := c.Do(ctx, method, urlpath, payload, opts...)
if err != nil {
return err
@@ -460,7 +460,7 @@ func (c *Client) ReadPlain(ctx context.Context, dest interface{}, method, urlpat
// GetPlainUnquote reads the response body as raw text and tries to unquote it,
// useful when the remote server sends a single key as a value but due to backend mistake
// it sends it as JSON (quoted) instead of plain text.
func (c *Client) GetPlainUnquote(ctx context.Context, method, urlpath string, payload interface{}, opts ...RequestOption) (string, error) {
func (c *Client) GetPlainUnquote(ctx context.Context, method, urlpath string, payload any, opts ...RequestOption) (string, error) {
var bodyStr string
if err := c.ReadPlain(ctx, &bodyStr, method, urlpath, payload, opts...); err != nil {
return "", err
@@ -479,7 +479,7 @@ func (c *Client) GetPlainUnquote(ctx context.Context, method, urlpath string, pa
// content-type and content-length of the original request.
//
// Returns the amount of bytes written to "dest".
func (c *Client) WriteTo(ctx context.Context, dest io.Writer, method, urlpath string, payload interface{}, opts ...RequestOption) (int64, error) {
func (c *Client) WriteTo(ctx context.Context, dest io.Writer, method, urlpath string, payload any, opts ...RequestOption) (int64, error) {
if payload != nil {
opts = append(opts, RequestHeader(true, contentTypeKey, contentTypeJSON))
}
@@ -508,7 +508,7 @@ func (c *Client) WriteTo(ctx context.Context, dest io.Writer, method, urlpath st
// Note that this is strict in order to catch bad actioners fast,
// e.g. it wont try to read plain text if not specified on
// the response headers and the dest is a *string.
func BindResponse(resp *http.Response, dest interface{}) (err error) {
func BindResponse(resp *http.Response, dest any) (err error) {
contentType := trimHeader(resp.Header.Get(contentTypeKey))
switch contentType {
case contentTypeJSON: // the most common scenario on successful responses.

View File

@@ -41,7 +41,7 @@ func TestClientJSON(t *testing.T) {
client.DrainResponseBody(resp)
}
func sendJSON(t *testing.T, v interface{}) http.HandlerFunc {
func sendJSON(t *testing.T, v any) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
if err := json.NewEncoder(w).Encode(v); err != nil {
@@ -50,7 +50,7 @@ func sendJSON(t *testing.T, v interface{}) http.HandlerFunc {
}
}
func readJSON(t *testing.T, ptr interface{}, expected interface{}) http.HandlerFunc {
func readJSON(t *testing.T, ptr any, expected any) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if err := json.NewDecoder(r.Body).Decode(ptr); err != nil {
t.Fatal(err)

View File

@@ -62,7 +62,7 @@ func GetError(err error) (APIError, bool) {
}
// DecodeError binds a json error to the "destPtr".
func DecodeError(err error, destPtr interface{}) error {
func DecodeError(err error, destPtr any) error {
apiErr, ok := GetError(err)
if !ok {
return err

View File

@@ -18,7 +18,7 @@ var (
Join = errors.Join
)
func sprintf(format string, args ...interface{}) string {
func sprintf(format string, args ...any) string {
if len(args) > 0 {
return fmt.Sprintf(format, args...)
}

View File

@@ -281,12 +281,12 @@ func (e ErrorCodeName) Details(ctx *context.Context, msg, details string) {
}
// Data sends an error with a message and json data to the client.
func (e ErrorCodeName) Data(ctx *context.Context, msg string, data interface{}) {
func (e ErrorCodeName) Data(ctx *context.Context, msg string, data any) {
fail(ctx, e, msg, "", nil, data)
}
// DataWithDetails sends an error with a message, details and json data to the client.
func (e ErrorCodeName) DataWithDetails(ctx *context.Context, msg, details string, data interface{}) {
func (e ErrorCodeName) DataWithDetails(ctx *context.Context, msg, details string, data any) {
fail(ctx, e, msg, details, nil, data)
}
@@ -295,7 +295,7 @@ func (e ErrorCodeName) Validation(ctx *context.Context, validationErrors ...Vali
e.validation(ctx, validationErrors)
}
func (e ErrorCodeName) validation(ctx *context.Context, validationErrors interface{}) {
func (e ErrorCodeName) validation(ctx *context.Context, validationErrors any) {
fail(ctx, e, "validation failure", "fields were invalid", validationErrors, nil)
}
@@ -339,7 +339,7 @@ func (e ErrorCodeName) Err(ctx *context.Context, err error) {
// error using the "LogError" package-level function, which can be customized.
//
// See "LogErr" too.
func (e ErrorCodeName) Log(ctx *context.Context, format string, args ...interface{}) {
func (e ErrorCodeName) Log(ctx *context.Context, format string, args ...any) {
if SkipCanceled {
if ctx.IsCanceled() {
return
@@ -471,7 +471,7 @@ type Error struct {
ErrorCode ErrorCode `json:"http_error_code" yaml:"HTTPErrorCode"`
Message string `json:"message,omitempty" yaml:"Message"`
Details string `json:"details,omitempty" yaml:"Details"`
Validation interface{} `json:"validation,omitempty" yaml:"Validation,omitempty"`
Validation any `json:"validation,omitempty" yaml:"Validation,omitempty"`
Data json.RawMessage `json:"data,omitempty" yaml:"Data,omitempty"` // any other custom json data.
}
@@ -496,7 +496,7 @@ func (err *Error) Error() string {
return sprintf("iris http wire error: canonical name: %s, http status code: %d, message: %s, details: %s", err.ErrorCode.CanonicalName, err.ErrorCode.Status, err.Message, err.Details)
}
func fail(ctx *context.Context, codeName ErrorCodeName, msg, details string, validationErrors interface{}, dataValue interface{}) {
func fail(ctx *context.Context, codeName ErrorCodeName, msg, details string, validationErrors any, dataValue any) {
errorCode, ok := errorCodeMap[codeName]
if !ok {
// This SHOULD NEVER happen, all ErrorCodeNames MUST be registered.

View File

@@ -64,7 +64,7 @@ func Handle(ctx *context.Context, resp any, err error) bool {
}
// checkNaN checks if any exported field in the struct is NaN and returns an error if it is.
func checkNaN(v interface{}) error {
func checkNaN(v any) error {
val := reflect.ValueOf(v)
return checkNaNRecursive(val, val.Type().Name())
}

View File

@@ -14,7 +14,7 @@ type ValidationError interface {
error
GetField() string
GetValue() interface{}
GetValue() any
GetReason() string
}

View File

@@ -77,7 +77,7 @@ func (t DayTime) String() string {
}
// Scan completes the sql driver.Scanner interface.
func (t *DayTime) Scan(src interface{}) error {
func (t *DayTime) Scan(src any) error {
switch v := src.(type) {
case time.Time: // type was set to timestamp
if v.IsZero() {

View File

@@ -16,7 +16,7 @@ func (d Duration) MarshalJSON() ([]byte, error) {
}
func (d *Duration) UnmarshalJSON(b []byte) error {
var v interface{}
var v any
if err := json.Unmarshal(b, &v); err != nil {
return err
}

View File

@@ -376,7 +376,7 @@ func (t ISO8601) Value() (driver.Value, error) {
}
// Scan completes the sql driver.Scanner interface.
func (t *ISO8601) Scan(src interface{}) error {
func (t *ISO8601) Scan(src any) error {
switch v := src.(type) {
case time.Time: // type was set to timestamp
if v.IsZero() {

View File

@@ -108,7 +108,7 @@ func (t KitchenTime) String() string {
// Scan completes the pg and native sql driver.Scanner interface
// reading functionality of a custom type.
func (t *KitchenTime) Scan(src interface{}) error {
func (t *KitchenTime) Scan(src any) error {
switch v := src.(type) {
case time.Time: // type was set to timestamp.
if v.IsZero() {

View File

@@ -155,7 +155,7 @@ func (t SimpleDate) String() string {
// Scan completes the pg and native sql driver.Scanner interface
// reading functionality of a custom type.
func (t *SimpleDate) Scan(src interface{}) error {
func (t *SimpleDate) Scan(src any) error {
switch v := src.(type) {
case time.Time: // type was set to timestamp
if v.IsZero() {
@@ -209,7 +209,7 @@ func (t SimpleDates) DateStrings() []string {
}
// Scan completes the pg and native sql driver.Scanner interface.
func (t *SimpleDates) Scan(src interface{}) error {
func (t *SimpleDates) Scan(src any) error {
if src == nil {
return nil
}

View File

@@ -68,7 +68,7 @@ func (d *TimeNotationDuration) UnmarshalJSON(b []byte) error {
return nil
}
var v interface{}
var v any
if err := json.Unmarshal(b, &v); err != nil {
return err
}

View File

@@ -15,7 +15,7 @@ type Zeroer interface {
// IsZero reports whether "v" is zero value or no.
// The given "v" value can complete the Zeroer interface
// which can be used to customize the behavior for each type of "v".
func IsZero(v interface{}) bool {
func IsZero(v any) bool {
switch t := v.(type) {
case Zeroer: // completes the time.Time as well.
return t.IsZero()

View File

@@ -51,22 +51,22 @@ func NewSchema() *Schema {
var DefaultSchema = NewSchema()
// Register caches a struct value to the default schema.
func Register(tableName string, value interface{}) *Schema {
func Register(tableName string, value any) *Schema {
return DefaultSchema.Register(tableName, value)
}
// Query is a shortcut of executing a query and bind the result to "dst".
func Query(ctx context.Context, db *sql.DB, dst interface{}, query string, args ...interface{}) error {
func Query(ctx context.Context, db *sql.DB, dst any, query string, args ...any) error {
return DefaultSchema.Query(ctx, db, dst, query, args...)
}
// Bind sets "dst" to the result of "src" and reports any errors.
func Bind(dst interface{}, src *sql.Rows) error {
func Bind(dst any, src *sql.Rows) error {
return DefaultSchema.Bind(dst, src)
}
// Register caches a struct value to the schema.
func (s *Schema) Register(tableName string, value interface{}) *Schema {
func (s *Schema) Register(tableName string, value any) *Schema {
typ := reflect.TypeOf(value)
for typ.Kind() == reflect.Ptr {
typ = typ.Elem()
@@ -97,7 +97,7 @@ func (s *Schema) Register(tableName string, value interface{}) *Schema {
}
// Query is a shortcut of executing a query and bind the result to "dst".
func (s *Schema) Query(ctx context.Context, db *sql.DB, dst interface{}, query string, args ...interface{}) error {
func (s *Schema) Query(ctx context.Context, db *sql.DB, dst any, query string, args ...any) error {
rows, err := db.QueryContext(ctx, query, args...)
if err != nil {
return err
@@ -112,7 +112,7 @@ func (s *Schema) Query(ctx context.Context, db *sql.DB, dst interface{}, query s
}
// Bind sets "dst" to the result of "src" and reports any errors.
func (s *Schema) Bind(dst interface{}, src *sql.Rows) error {
func (s *Schema) Bind(dst any, src *sql.Rows) error {
typ := reflect.TypeOf(dst)
if typ.Kind() != reflect.Ptr {
return fmt.Errorf("sqlx: bind: destination not a pointer")
@@ -176,7 +176,7 @@ func (s *Schema) Bind(dst interface{}, src *sql.Rows) error {
}
}
func (r *Row) bindSingle(typ reflect.Type, val reflect.Value, columnTypes []*sql.ColumnType, scanner interface{ Scan(...interface{}) error }) error {
func (r *Row) bindSingle(typ reflect.Type, val reflect.Value, columnTypes []*sql.ColumnType, scanner interface{ Scan(...any) error }) error {
fieldPtrs, err := r.lookupStructFieldPtrs(typ, val, columnTypes)
if err != nil {
return fmt.Errorf("sqlx: bind: table: %q: %w", r.Name, err)
@@ -185,8 +185,8 @@ func (r *Row) bindSingle(typ reflect.Type, val reflect.Value, columnTypes []*sql
return scanner.Scan(fieldPtrs...)
}
func (r *Row) lookupStructFieldPtrs(typ reflect.Type, val reflect.Value, columnTypes []*sql.ColumnType) ([]interface{}, error) {
fieldPtrs := make([]interface{}, 0, len(columnTypes))
func (r *Row) lookupStructFieldPtrs(typ reflect.Type, val reflect.Value, columnTypes []*sql.ColumnType) ([]any, error) {
fieldPtrs := make([]any, 0, len(columnTypes))
for _, columnType := range columnTypes {
columnName := columnType.Name()