mirror of
https://github.com/kataras/iris.git
synced 2025-12-23 21:07:03 +00:00
update dependencies
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user