1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-10 05:25:58 +00:00

CI: minor: use the new exclude-paths (dependabot PR approved some days ago)

This commit is contained in:
Gerasimos (Makis) Maropoulos
2025-08-16 22:48:38 +03:00
parent a8a3afea22
commit 92164cee52
37 changed files with 268 additions and 266 deletions

View File

@@ -30,7 +30,7 @@ type Application interface {
// Validate validates a value and returns nil if passed or
// the failure reason if not.
Validate(interface{}) error
Validate(any) error
// Minifier returns the minifier instance.
// By default it can minifies:
@@ -44,7 +44,7 @@ type Application interface {
//
// Use context.View to render templates to the client instead.
// Returns an error on failure, otherwise nil.
View(writer io.Writer, filename string, layout string, bindingData interface{}) error
View(writer io.Writer, filename string, layout string, bindingData any) error
// GetContextPool returns the Iris sync.Pool which holds the contexts values.
// Iris automatically releases the request context, so you don't have to use it.

View File

@@ -170,7 +170,7 @@ func NewCompressReader(src io.Reader, encoding string) (*CompressReader, error)
}, nil
}
var compressWritersPool = sync.Pool{New: func() interface{} { return &CompressResponseWriter{} }}
var compressWritersPool = sync.Pool{New: func() any { return &CompressResponseWriter{} }}
// AddCompressHeaders just adds the headers "Vary" to "Accept-Encoding"
// and "Content-Encoding" to the given encoding.

View File

@@ -96,5 +96,5 @@ type ConfigurationReadOnly interface {
// GetHostProxyHeaders returns the HostProxyHeaders field.
GetHostProxyHeaders() map[string]bool
// GetOther returns the Other field.
GetOther() map[string]interface{}
GetOther() map[string]any
}

View File

@@ -84,7 +84,7 @@ type (
// Unmarshaler is the interface implemented by types that can unmarshal any raw data.
// TIP INFO: Any pointer to a value which implements the BodyDecoder can be override the unmarshaler.
Unmarshaler interface {
Unmarshal(data []byte, outPtr interface{}) error
Unmarshal(data []byte, outPtr any) error
}
// UnmarshalerFunc a shortcut for the Unmarshaler interface
@@ -92,20 +92,20 @@ type (
// See 'Unmarshaler' and 'BodyDecoder' for more.
//
// Example: https://github.com/kataras/iris/blob/main/_examples/request-body/read-custom-via-unmarshaler/main.go
UnmarshalerFunc func(data []byte, outPtr interface{}) error
UnmarshalerFunc func(data []byte, outPtr any) error
// DecodeFunc is a generic type of decoder function.
// When the returned error is not nil the decode operation
// is terminated and the error is received by the ReadJSONStream method,
// otherwise it continues to read the next available object.
// Look the `Context.ReadJSONStream` method.
DecodeFunc func(outPtr interface{}) error
DecodeFunc func(outPtr any) error
)
// Unmarshal parses the X-encoded data and stores the result in the value pointed to by v.
// Unmarshal uses the inverse of the encodings that Marshal uses, allocating maps,
// slices, and pointers as necessary.
func (u UnmarshalerFunc) Unmarshal(data []byte, v interface{}) error {
func (u UnmarshalerFunc) Unmarshal(data []byte, v any) error {
return u(data, v)
}
@@ -118,8 +118,8 @@ var LimitRequestBodySize = func(maxRequestBodySizeBytes int64) Handler {
}
}
// Map is just a type alias of the map[string]interface{} type.
type Map = map[string]interface{}
// Map is just a type alias of the map[string]any type.
type Map = map[string]any
// Context is the midle-man server's "object" dealing with incoming requests.
//
@@ -433,7 +433,7 @@ type goroutines struct {
mu sync.RWMutex
}
var acquireGoroutines = func() interface{} {
var acquireGoroutines = func() any {
return &goroutines{wg: new(sync.WaitGroup)}
}
@@ -840,7 +840,7 @@ func (ctx *Context) StopWithPlainError(statusCode int, err error) {
//
// If the status code is a failure one then
// it will also fire the specified error code handler.
func (ctx *Context) StopWithJSON(statusCode int, jsonObject interface{}) error {
func (ctx *Context) StopWithJSON(statusCode int, jsonObject any) error {
ctx.StopWithStatus(statusCode)
return ctx.writeJSON(jsonObject, &DefaultJSONOptions) // do not modify - see errors.DefaultContextErrorHandler.
}
@@ -1359,7 +1359,7 @@ func (ctx *Context) GetLocale() Locale {
// See `GetLocale` too.
//
// Example: https://github.com/kataras/iris/tree/main/_examples/i18n
func (ctx *Context) Tr(key string, args ...interface{}) string {
func (ctx *Context) Tr(key string, args ...any) string {
return ctx.app.I18nReadOnly().TrContext(ctx, key, args...)
}
@@ -2692,17 +2692,17 @@ func (ctx *Context) GetBody() ([]byte, error) {
// Validator is the validator for request body on Context methods such as
// ReadJSON, ReadMsgPack, ReadXML, ReadYAML, ReadForm, ReadQuery, ReadBody and e.t.c.
type Validator interface {
Struct(interface{}) error
Struct(any) error
// If community asks for more than a struct validation on JSON, XML, MsgPack, Form, Query and e.t.c
// then we should add more methods here, alternative approach would be to have a
// `Validator:Validate(interface{}) error` and a map[reflect.Kind]Validator instead.
// `Validator:Validate(any) error` and a map[reflect.Kind]Validator instead.
}
// UnmarshalBody reads the request's body and binds it to a value or pointer of any type
// Examples of usage: context.ReadJSON, context.ReadXML.
//
// Example: https://github.com/kataras/iris/blob/main/_examples/request-body/read-custom-via-unmarshaler/main.go
func (ctx *Context) UnmarshalBody(outPtr interface{}, unmarshaler Unmarshaler) error {
func (ctx *Context) UnmarshalBody(outPtr any, unmarshaler Unmarshaler) error {
if ctx.request.Body == nil {
return fmt.Errorf("unmarshal: empty body: %w", ErrNotFound)
}
@@ -2766,7 +2766,7 @@ type JSONReader struct { // Note(@kataras): struct instead of optional funcs to
ArrayStream bool
}
var ReadJSON = func(ctx *Context, outPtr interface{}, opts ...JSONReader) error {
var ReadJSON = func(ctx *Context, outPtr any, opts ...JSONReader) error {
var body io.Reader
if ctx.IsRecordingBody() {
@@ -2800,7 +2800,7 @@ var ReadJSON = func(ctx *Context, outPtr interface{}, opts ...JSONReader) error
// ReadJSON reads JSON from request's body and binds it to a value of any json-valid type.
//
// Example: https://github.com/kataras/iris/blob/main/_examples/request-body/read-json/main.go
func (ctx *Context) ReadJSON(outPtr interface{}, opts ...JSONReader) error {
func (ctx *Context) ReadJSON(outPtr any, opts ...JSONReader) error {
return ReadJSON(ctx, outPtr, opts...)
}
@@ -2846,14 +2846,14 @@ func (ctx *Context) ReadJSONStream(onDecode func(DecodeFunc) error, opts ...JSON
// ReadXML reads XML from request's body and binds it to a value of any xml-valid type.
//
// Example: https://github.com/kataras/iris/blob/main/_examples/request-body/read-xml/main.go
func (ctx *Context) ReadXML(outPtr interface{}) error {
func (ctx *Context) ReadXML(outPtr any) error {
return ctx.UnmarshalBody(outPtr, UnmarshalerFunc(xml.Unmarshal))
}
// ReadYAML reads YAML from request's body and binds it to the "outPtr" value.
//
// Example: https://github.com/kataras/iris/blob/main/_examples/request-body/read-yaml/main.go
func (ctx *Context) ReadYAML(outPtr interface{}) error {
func (ctx *Context) ReadYAML(outPtr any) error {
return ctx.UnmarshalBody(outPtr, UnmarshalerFunc(yaml.Unmarshal))
}
@@ -2967,7 +2967,7 @@ const CSRFTokenFormKey = "csrf.token"
// to change this behavior globally, set the `context.CSRFTokenFormKey` to an empty value.
//
// Example: https://github.com/kataras/iris/blob/main/_examples/request-body/read-form/main.go
func (ctx *Context) ReadForm(formObject interface{}) error {
func (ctx *Context) ReadForm(formObject any) error {
values := ctx.FormValues()
if len(values) == 0 {
if ctx.app.ConfigurationReadOnly().GetFireEmptyFormError() {
@@ -3124,7 +3124,7 @@ func distinctStrings(values []string) []string {
// ReadQuery binds URL Query to "ptr". The struct field tag is "url".
//
// Example: https://github.com/kataras/iris/blob/main/_examples/request-body/read-query/main.go
func (ctx *Context) ReadQuery(ptr interface{}) error {
func (ctx *Context) ReadQuery(ptr any) error {
values := ctx.getQuery()
if len(values) == 0 {
if ctx.app.ConfigurationReadOnly().GetFireEmptyFormError() {
@@ -3144,7 +3144,7 @@ func (ctx *Context) ReadQuery(ptr interface{}) error {
// ReadHeaders binds request headers to "ptr". The struct field tag is "header".
//
// Example: https://github.com/kataras/iris/blob/main/_examples/request-body/read-headers/main.go
func (ctx *Context) ReadHeaders(ptr interface{}) error {
func (ctx *Context) ReadHeaders(ptr any) error {
err := schema.DecodeHeaders(ctx.request.Header, ptr)
if err != nil {
return err
@@ -3156,7 +3156,7 @@ func (ctx *Context) ReadHeaders(ptr interface{}) error {
// ReadParams binds URI Dynamic Path Parameters to "ptr". The struct field tag is "param".
//
// Example: https://github.com/kataras/iris/blob/main/_examples/request-body/read-params/main.go
func (ctx *Context) ReadParams(ptr interface{}) error {
func (ctx *Context) ReadParams(ptr any) error {
n := ctx.params.Len()
if n == 0 {
return nil
@@ -3183,7 +3183,7 @@ func (ctx *Context) ReadParams(ptr interface{}) error {
// to the "ptr" pointer struct value.
// The struct fields may contain "url" or "param" binding tags.
// If a validator exists then it validates the result too.
func (ctx *Context) ReadURL(ptr interface{}) error {
func (ctx *Context) ReadURL(ptr any) error {
values := make(map[string][]string, ctx.params.Len())
ctx.params.Visit(func(key string, value string) {
values[key] = strings.Split(value, "/")
@@ -3235,7 +3235,7 @@ func (ctx *Context) ReadJSONProtobuf(ptr proto.Message, opts ...ProtoUnmarshalOp
}
// ReadMsgPack binds the request body of msgpack format to the "ptr" and returns any error.
func (ctx *Context) ReadMsgPack(ptr interface{}) error {
func (ctx *Context) ReadMsgPack(ptr any) error {
rawData, err := ctx.GetBody()
if err != nil {
return err
@@ -3255,7 +3255,7 @@ func (ctx *Context) ReadMsgPack(ptr interface{}) error {
// JSON, Protobuf, MsgPack, XML, YAML, MultipartForm and binds the result to the "ptr".
// As a special case if the "ptr" was a pointer to string or []byte
// then it will bind it to the request body as it is.
func (ctx *Context) ReadBody(ptr interface{}) error {
func (ctx *Context) ReadBody(ptr any) error {
// If the ptr is string or byte, read the body as it's.
switch v := ptr.(type) {
case *string:
@@ -3353,7 +3353,7 @@ func (ctx *Context) Write(rawBody []byte) (int, error) {
// Writef formats according to a format specifier and writes to the response.
//
// Returns the number of bytes written and any write error encountered.
func (ctx *Context) Writef(format string, a ...interface{}) (n int, err error) {
func (ctx *Context) Writef(format string, a ...any) (n int, err error) {
/* if len(a) == 0 {
return ctx.WriteString(format)
} ^ No, let it complain about arguments, because go test will do even if the app is running.
@@ -3738,7 +3738,7 @@ func (ctx *Context) ViewLayout(layoutTmplFile string) {
// Look .ViewLayout and .View too.
//
// Example: https://github.com/kataras/iris/tree/main/_examples/view/context-view-data/
func (ctx *Context) ViewData(key string, value interface{}) {
func (ctx *Context) ViewData(key string, value any) {
viewDataContextKey := ctx.app.ConfigurationReadOnly().GetViewDataContextKey()
if key == "" {
ctx.values.Set(viewDataContextKey, value)
@@ -3757,7 +3757,7 @@ func (ctx *Context) ViewData(key string, value interface{}) {
}
// GetViewData returns the values registered by `context#ViewData`.
// The return value is `map[string]interface{}`, this means that
// The return value is `map[string]any`, this means that
// if a custom struct registered to ViewData then this function
// will try to parse it to map, if failed then the return value is nil
// A check for nil is always a good practise if different
@@ -3765,14 +3765,14 @@ func (ctx *Context) ViewData(key string, value interface{}) {
//
// Similarly to `viewData := ctx.Values().Get("iris.view.data")` or
// `viewData := ctx.Values().Get(ctx.Application().ConfigurationReadOnly().GetViewDataContextKey())`.
func (ctx *Context) GetViewData() map[string]interface{} {
func (ctx *Context) GetViewData() map[string]any {
if v := ctx.values.Get(ctx.app.ConfigurationReadOnly().GetViewDataContextKey()); v != nil {
// if pure map[string]interface{}
// if pure map[string]any
if viewData, ok := v.(Map); ok {
return viewData
}
// if struct, convert it to map[string]interface{}
// if struct, convert it to map[string]any
if structs.IsStruct(v) {
return structs.Map(v)
}
@@ -3936,7 +3936,7 @@ func (ctx *Context) FallbackView(providers ...FallbackViewProvider) {
// Look .ViewData and .ViewLayout too.
//
// Examples: https://github.com/kataras/iris/tree/main/_examples/view
func (ctx *Context) View(filename string, optionalViewModel ...interface{}) error {
func (ctx *Context) View(filename string, optionalViewModel ...any) error {
ctx.ContentType(ContentHTMLHeaderValue)
err := ctx.renderView(filename, optionalViewModel...)
@@ -3959,11 +3959,11 @@ func (ctx *Context) View(filename string, optionalViewModel ...interface{}) erro
return err
}
func (ctx *Context) renderView(filename string, optionalViewModel ...interface{}) error {
func (ctx *Context) renderView(filename string, optionalViewModel ...any) error {
cfg := ctx.app.ConfigurationReadOnly()
layout := ctx.values.GetString(cfg.GetViewLayoutContextKey())
var bindingData interface{}
var bindingData any
if len(optionalViewModel) > 0 /* Don't do it: can break a lot of servers: && optionalViewModel[0] != nil */ {
// a nil can override the existing data or model sent by `ViewData`.
bindingData = optionalViewModel[0]
@@ -4124,7 +4124,7 @@ var (
secureJSONPrefix = []byte("while(1);")
)
func (ctx *Context) handleSpecialJSONResponseValue(v interface{}, options *JSON) (bool, int, error) {
func (ctx *Context) handleSpecialJSONResponseValue(v any, options *JSON) (bool, int, error) {
if ctx.app.ConfigurationReadOnly().GetEnableProtoJSON() {
if m, ok := v.(proto.Message); ok {
protoJSON := ProtoMarshalOptions{}
@@ -4160,7 +4160,7 @@ func (ctx *Context) handleSpecialJSONResponseValue(v interface{}, options *JSON)
}
// WriteJSON marshals the given interface object and writes the JSON response to the 'writer'.
var WriteJSON = func(ctx *Context, v interface{}, options *JSON) error {
var WriteJSON = func(ctx *Context, v any, options *JSON) error {
if !options.Secure && !options.ASCII && options.Prefix == "" {
// jsoniterConfig := jsoniter.Config{
// EscapeHTML: !options.UnescapeHTML,
@@ -4343,7 +4343,7 @@ func (ctx *Context) RenderComponent(component Component) error {
//
// Customize the behavior of every `Context.JSON“ can be achieved
// by modifying the package-level `WriteJSON` function on program initilization.
func (ctx *Context) JSON(v interface{}, opts ...JSON) (err error) {
func (ctx *Context) JSON(v any, opts ...JSON) (err error) {
var options *JSON
if len(opts) > 0 {
options = &opts[0]
@@ -4363,7 +4363,7 @@ func (ctx *Context) JSON(v interface{}, opts ...JSON) (err error) {
return
}
func (ctx *Context) writeJSON(v interface{}, options *JSON) error {
func (ctx *Context) writeJSON(v any, options *JSON) error {
ctx.ContentType(ContentJSONHeaderValue)
// After content type given and before everything else, try handle proto or easyjson, no matter the performance mode.
@@ -4377,7 +4377,7 @@ func (ctx *Context) writeJSON(v interface{}, options *JSON) error {
var finishCallbackB = []byte(");")
// WriteJSONP marshals the given interface object and writes the JSONP response to the writer.
var WriteJSONP = func(ctx *Context, v interface{}, options *JSONP) (err error) {
var WriteJSONP = func(ctx *Context, v any, options *JSONP) (err error) {
if callback := options.Callback; callback != "" {
_, err = ctx.Write(stringToBytes(callback + "("))
if err != nil {
@@ -4406,7 +4406,7 @@ var DefaultJSONPOptions = JSONP{}
// It reports any JSON parser or write errors back to the caller.
// Look the Application.SetContextErrorHandler to override the
// default status code 500 with a custom error response.
func (ctx *Context) JSONP(v interface{}, opts ...JSONP) (err error) {
func (ctx *Context) JSONP(v any, opts ...JSONP) (err error) {
var options *JSONP
if len(opts) > 0 {
options = &opts[0]
@@ -4426,13 +4426,13 @@ func (ctx *Context) JSONP(v interface{}, opts ...JSONP) (err error) {
type xmlMapEntry struct {
XMLName xml.Name
Value interface{} `xml:",chardata"`
Value any `xml:",chardata"`
}
// XMLMap wraps a map[string]interface{} to compatible xml marshaler,
// XMLMap wraps a map[string]any to compatible xml marshaler,
// in order to be able to render maps as XML on the `Context.XML` method.
//
// Example: `Context.XML(XMLMap("Root", map[string]interface{}{...})`.
// Example: `Context.XML(XMLMap("Root", map[string]any{...})`.
func XMLMap(elementName string, v Map) xml.Marshaler {
return xmlMap{
entries: v,
@@ -4468,7 +4468,7 @@ func (m xmlMap) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
}
// WriteXML marshals the given interface object and writes the XML response to the writer.
var WriteXML = func(ctx *Context, v interface{}, options *XML) error {
var WriteXML = func(ctx *Context, v any, options *XML) error {
if prefix := options.Prefix; prefix != "" {
_, err := ctx.Write(stringToBytes(prefix))
if err != nil {
@@ -4495,7 +4495,7 @@ var DefaultXMLOptions = XML{}
// It reports any XML parser or write errors back to the caller.
// Look the Application.SetContextErrorHandler to override the
// default status code 500 with a custom error response.
func (ctx *Context) XML(v interface{}, opts ...XML) (err error) {
func (ctx *Context) XML(v any, opts ...XML) (err error) {
var options *XML
if len(opts) > 0 {
options = &opts[0]
@@ -4524,7 +4524,7 @@ func (ctx *Context) XML(v interface{}, opts ...XML) (err error) {
// send a response of content type "application/problem+xml" instead.
//
// Read more at: https://github.com/kataras/iris/blob/main/_examples/routing/http-errors.
func (ctx *Context) Problem(v interface{}, opts ...ProblemOptions) error {
func (ctx *Context) Problem(v any, opts ...ProblemOptions) error {
options := DefaultProblemOptions
if len(opts) > 0 {
options = opts[0]
@@ -4605,7 +4605,7 @@ func (ctx *Context) Markdown(markdownB []byte, opts ...Markdown) (err error) {
}
// WriteYAML sends YAML response to the client.
var WriteYAML = func(ctx *Context, v interface{}, indentSpace int) error {
var WriteYAML = func(ctx *Context, v any, indentSpace int) error {
encoder := yaml.NewEncoder(ctx.writer)
encoder.SetIndent(indentSpace)
@@ -4621,7 +4621,7 @@ var WriteYAML = func(ctx *Context, v interface{}, indentSpace int) error {
// It reports any YAML parser or write errors back to the caller.
// Look the Application.SetContextErrorHandler to override the
// default status code 500 with a custom error response.
func (ctx *Context) YAML(v interface{}) error {
func (ctx *Context) YAML(v any) error {
ctx.ContentType(ContentYAMLHeaderValue)
err := WriteYAML(ctx, v, 0)
@@ -4634,7 +4634,7 @@ func (ctx *Context) YAML(v interface{}) error {
}
// TextYAML calls the Context.YAML method but with the text/yaml content type instead.
func (ctx *Context) TextYAML(v interface{}) error {
func (ctx *Context) TextYAML(v any) error {
ctx.ContentType(ContentYAMLTextHeaderValue)
err := WriteYAML(ctx, v, 4)
@@ -4672,7 +4672,7 @@ func (ctx *Context) Protobuf(v proto.Message) (int, error) {
// It reports any message pack or write errors back to the caller.
// Look the Application.SetContextErrorHandler to override the
// default status code 500 with a custom error response.
func (ctx *Context) MsgPack(v interface{}) (int, error) {
func (ctx *Context) MsgPack(v any) (int, error) {
out, err := msgpack.Marshal(v)
if err != nil {
ctx.handleContextError(err)
@@ -4702,7 +4702,7 @@ var ErrContentNotSupported = errors.New("unsupported content")
//
// See the `N` struct too.
type ContentSelector interface {
SelectContent(mime string) interface{}
SelectContent(mime string) any
}
// ContentNegotiator is the interface which structs can implement
@@ -4732,13 +4732,13 @@ type N struct {
Markdown []byte
Binary []byte
JSON interface{}
JSON any
Problem Problem
JSONP interface{}
XML interface{}
YAML interface{}
Protobuf interface{}
MsgPack interface{}
JSONP any
XML any
YAML any
Protobuf any
MsgPack any
Other []byte // custom content types.
}
@@ -4746,7 +4746,7 @@ type N struct {
var _ ContentSelector = N{}
// SelectContent returns a content based on the matched negotiated "mime".
func (n N) SelectContent(mime string) interface{} {
func (n N) SelectContent(mime string) any {
switch mime {
case ContentTextHeaderValue:
return n.Text
@@ -4842,7 +4842,7 @@ func parseHeader(headerValue string) []string {
// Supports the above without quality values.
//
// Read more at: https://github.com/kataras/iris/tree/main/_examples/response-writer/content-negotiation
func (ctx *Context) Negotiate(v interface{}) (int, error) {
func (ctx *Context) Negotiate(v any) (int, error) {
contentType, charset, encoding, content := ctx.Negotiation().Build()
if v == nil {
v = content
@@ -4977,8 +4977,8 @@ func (ctx *Context) Negotiate(v interface{}) (int, error) {
type NegotiationBuilder struct {
Accept NegotiationAcceptBuilder
mime []string // we need order.
contents map[string]interface{} // map to the "mime" and content should be rendered if that mime requested.
mime []string // we need order.
contents map[string]any // map to the "mime" and content should be rendered if that mime requested.
charset []string
encoding []string
}
@@ -4987,7 +4987,7 @@ type NegotiationBuilder struct {
// through `Context.Negotiate` when this mime type is accepted by client.
//
// Returns itself for recursive calls.
func (n *NegotiationBuilder) MIME(mime string, content interface{}) *NegotiationBuilder {
func (n *NegotiationBuilder) MIME(mime string, content any) *NegotiationBuilder {
mimes := parseHeader(mime) // if contains more than one sep by commas ",".
if content == nil {
n.mime = append(n.mime, mimes...)
@@ -4995,7 +4995,7 @@ func (n *NegotiationBuilder) MIME(mime string, content interface{}) *Negotiation
}
if n.contents == nil {
n.contents = make(map[string]interface{})
n.contents = make(map[string]any)
}
for _, m := range mimes {
@@ -5012,7 +5012,7 @@ func (n *NegotiationBuilder) MIME(mime string, content interface{}) *Negotiation
//
// Returns itself for recursive calls.
func (n *NegotiationBuilder) Text(v ...string) *NegotiationBuilder {
var content interface{}
var content any
if len(v) > 0 {
content = v[0]
}
@@ -5025,7 +5025,7 @@ func (n *NegotiationBuilder) Text(v ...string) *NegotiationBuilder {
//
// Returns itself for recursive calls.
func (n *NegotiationBuilder) HTML(v ...string) *NegotiationBuilder {
var content interface{}
var content any
if len(v) > 0 {
content = v[0]
}
@@ -5038,7 +5038,7 @@ func (n *NegotiationBuilder) HTML(v ...string) *NegotiationBuilder {
//
// Returns itself for recursive calls.
func (n *NegotiationBuilder) Markdown(v ...[]byte) *NegotiationBuilder {
var content interface{}
var content any
if len(v) > 0 {
content = v
}
@@ -5051,7 +5051,7 @@ func (n *NegotiationBuilder) Markdown(v ...[]byte) *NegotiationBuilder {
//
// Returns itself for recursive calls.
func (n *NegotiationBuilder) Binary(v ...[]byte) *NegotiationBuilder {
var content interface{}
var content any
if len(v) > 0 {
content = v[0]
}
@@ -5063,8 +5063,8 @@ func (n *NegotiationBuilder) Binary(v ...[]byte) *NegotiationBuilder {
// when a client accepts the "application/json" content type.
//
// Returns itself for recursive calls.
func (n *NegotiationBuilder) JSON(v ...interface{}) *NegotiationBuilder {
var content interface{}
func (n *NegotiationBuilder) JSON(v ...any) *NegotiationBuilder {
var content any
if len(v) > 0 {
content = v[0]
}
@@ -5076,8 +5076,8 @@ func (n *NegotiationBuilder) JSON(v ...interface{}) *NegotiationBuilder {
// when a client accepts the "application/problem+json" or the "application/problem+xml" content type.
//
// Returns itself for recursive calls.
func (n *NegotiationBuilder) Problem(v ...interface{}) *NegotiationBuilder {
var content interface{}
func (n *NegotiationBuilder) Problem(v ...any) *NegotiationBuilder {
var content any
if len(v) > 0 {
content = v[0]
}
@@ -5089,8 +5089,8 @@ func (n *NegotiationBuilder) Problem(v ...interface{}) *NegotiationBuilder {
// when a client accepts the "javascript/javascript" content type.
//
// Returns itself for recursive calls.
func (n *NegotiationBuilder) JSONP(v ...interface{}) *NegotiationBuilder {
var content interface{}
func (n *NegotiationBuilder) JSONP(v ...any) *NegotiationBuilder {
var content any
if len(v) > 0 {
content = v[0]
}
@@ -5102,8 +5102,8 @@ func (n *NegotiationBuilder) JSONP(v ...interface{}) *NegotiationBuilder {
// when a client accepts one of the "text/xml" or "application/xml" content types.
//
// Returns itself for recursive calls.
func (n *NegotiationBuilder) XML(v ...interface{}) *NegotiationBuilder {
var content interface{}
func (n *NegotiationBuilder) XML(v ...any) *NegotiationBuilder {
var content any
if len(v) > 0 {
content = v[0]
}
@@ -5115,8 +5115,8 @@ func (n *NegotiationBuilder) XML(v ...interface{}) *NegotiationBuilder {
// when a client accepts the "application/x-yaml" content type.
//
// Returns itself for recursive calls.
func (n *NegotiationBuilder) YAML(v ...interface{}) *NegotiationBuilder {
var content interface{}
func (n *NegotiationBuilder) YAML(v ...any) *NegotiationBuilder {
var content any
if len(v) > 0 {
content = v[0]
}
@@ -5128,8 +5128,8 @@ func (n *NegotiationBuilder) YAML(v ...interface{}) *NegotiationBuilder {
// when a client accepts the "application/x-yaml" content type.
//
// Returns itself for recursive calls.
func (n *NegotiationBuilder) TextYAML(v ...interface{}) *NegotiationBuilder {
var content interface{}
func (n *NegotiationBuilder) TextYAML(v ...any) *NegotiationBuilder {
var content any
if len(v) > 0 {
content = v[0]
}
@@ -5141,8 +5141,8 @@ func (n *NegotiationBuilder) TextYAML(v ...interface{}) *NegotiationBuilder {
// when a client accepts the "application/x-protobuf" content type.
//
// Returns itself for recursive calls.
func (n *NegotiationBuilder) Protobuf(v ...interface{}) *NegotiationBuilder {
var content interface{}
func (n *NegotiationBuilder) Protobuf(v ...any) *NegotiationBuilder {
var content any
if len(v) > 0 {
content = v[0]
}
@@ -5154,8 +5154,8 @@ func (n *NegotiationBuilder) Protobuf(v ...interface{}) *NegotiationBuilder {
// when a client accepts one of the "application/x-msgpack" or "application/msgpack" content types.
//
// Returns itself for recursive calls.
func (n *NegotiationBuilder) MsgPack(v ...interface{}) *NegotiationBuilder {
var content interface{}
func (n *NegotiationBuilder) MsgPack(v ...any) *NegotiationBuilder {
var content any
if len(v) > 0 {
content = v[0]
}
@@ -5165,8 +5165,8 @@ func (n *NegotiationBuilder) MsgPack(v ...interface{}) *NegotiationBuilder {
// Any registers a wildcard that can match any client's accept content type.
//
// Returns itself for recursive calls.
func (n *NegotiationBuilder) Any(v ...interface{}) *NegotiationBuilder {
var content interface{}
func (n *NegotiationBuilder) Any(v ...any) *NegotiationBuilder {
var content any
if len(v) > 0 {
content = v[0]
}
@@ -5209,7 +5209,7 @@ func (n *NegotiationBuilder) EncodingGzip() *NegotiationBuilder {
//
// The returned "content" can be nil if the matched "contentType" does not provide any value,
// in that case the `Context.Negotiate(v)` must be called with a non-nil value.
func (n *NegotiationBuilder) Build() (contentType, charset, encoding string, content interface{}) {
func (n *NegotiationBuilder) Build() (contentType, charset, encoding string, content any) {
contentType = negotiationMatch(n.Accept.accept, n.mime)
charset = negotiationMatch(n.Accept.charset, n.charset)
encoding = negotiationMatch(n.Accept.encoding, n.encoding)
@@ -5753,7 +5753,7 @@ type SecureCookie interface {
// You either need to provide exactly that amount or you derive the key from what you type in.
//
// See `Decode` too.
Encode(cookieName string, cookieValue interface{}) (string, error)
Encode(cookieName string, cookieValue any) (string, error)
// Decode should decode the cookie value.
// Should accept the cookie's name as its first argument,
// as second argument the encoded cookie value and as third argument the decoded value ptr.
@@ -5765,7 +5765,7 @@ type SecureCookie interface {
// You either need to provide exactly that amount or you derive the key from what you type in.
//
// See `Encode` too.
Decode(cookieName string, cookieValue string, cookieValuePtr interface{}) error
Decode(cookieName string, cookieValue string, cookieValuePtr any) error
}
// CookieEncoding accepts a value which implements `Encode` and `Decode` methods.
@@ -6202,7 +6202,7 @@ type DependenciesMap map[reflect.Type]reflect.Value
// in sake of minimum performance cost.
//
// See `UnregisterDependency` too.
func (ctx *Context) RegisterDependency(v interface{}) {
func (ctx *Context) RegisterDependency(v any) {
if v == nil {
return
}
@@ -6350,7 +6350,7 @@ func (ctx *Context) GetErrPublic() (bool, error) {
// which recovers from a manual panic.
type ErrPanicRecovery struct {
ErrPrivate
Cause interface{}
Cause any
Callers []string // file:line callers.
Stack []byte // the full debug stack.
RegisteredHandlers []string // file:line of all registered handlers.
@@ -6436,7 +6436,7 @@ const (
//
// Example at:
// https://github.com/kataras/iris/tree/main/_examples/routing/writing-a-middleware/share-funcs
func (ctx *Context) SetFunc(name string, fn interface{}, persistenceArgs ...interface{}) {
func (ctx *Context) SetFunc(name string, fn any, persistenceArgs ...any) {
f := newFunc(name, fn, persistenceArgs...)
ctx.values.Set(funcsContextPrefixKey+name, f)
}
@@ -6467,7 +6467,7 @@ func (ctx *Context) GetFunc(name string) (*Func, bool) {
//
// For a more complete solution without limiations navigate through
// the Iris Dependency Injection feature instead.
func (ctx *Context) CallFunc(name string, args ...interface{}) ([]reflect.Value, error) {
func (ctx *Context) CallFunc(name string, args ...any) ([]reflect.Value, error) {
fn, ok := ctx.GetFunc(name)
if !ok || fn == nil {
return nil, ErrNotFound
@@ -6484,14 +6484,14 @@ func (ctx *Context) CallFunc(name string, args ...interface{}) ([]reflect.Value,
// This method uses the `SetFunc` method under the hoods.
//
// See `Logout` method too.
func (ctx *Context) SetLogoutFunc(fn interface{}, persistenceArgs ...interface{}) {
func (ctx *Context) SetLogoutFunc(fn any, persistenceArgs ...any) {
ctx.SetFunc(funcLogoutContextKey, fn, persistenceArgs...)
}
// Logout calls the registered logout function.
// Returns ErrNotFound if a logout function was not specified
// by a prior call of `SetLogoutFunc`.
func (ctx *Context) Logout(args ...interface{}) error {
func (ctx *Context) Logout(args ...any) error {
_, err := ctx.CallFunc(funcLogoutContextKey, args...)
return err
}
@@ -6505,13 +6505,13 @@ const userContextKey = "iris.user"
//
// The "i" input argument can be:
// - A value which completes the User interface
// - A map[string]interface{}.
// - A map[string]any.
// - A value which does not complete the whole User interface
// - A value which does not complete the User interface at all
// (only its `User().GetRaw` method is available).
//
// Look the `User` method to retrieve it.
func (ctx *Context) SetUser(i interface{}) error {
func (ctx *Context) SetUser(i any) error {
if i == nil {
ctx.values.Remove(userContextKey)
return nil
@@ -6615,8 +6615,8 @@ func (ctx *Context) Err() error {
// if no value is associated with key. Successive calls to Value with
// the same key returns the same result.
//
// Shortcut of Request().Context().Value(key interface{}) interface{}.
func (ctx *Context) Value(key interface{}) interface{} {
// Shortcut of Request().Context().Value(key any) any.
func (ctx *Context) Value(key any) any {
if keyStr, ok := key.(string); ok { // check if the key is a type of string, which can be retrieved by the mem store.
if entry, exists := ctx.values.GetEntry(keyStr); exists {
return entry.ValueRaw
@@ -6633,14 +6633,14 @@ const idContextKey = "iris.context.id"
// so it can be rendered on `Context.String` method.
//
// See `GetID` and `middleware/requestid` too.
func (ctx *Context) SetID(id interface{}) {
func (ctx *Context) SetID(id any) {
ctx.values.Set(idContextKey, id)
}
// GetID returns the Request Context's ID.
// It returns nil if not given by a prior `SetID` call.
// See `middleware/requestid` too.
func (ctx *Context) GetID() interface{} {
func (ctx *Context) GetID() any {
return ctx.values.Get(idContextKey)
}

View File

@@ -13,16 +13,16 @@ var ErrInvalidArgs = errors.New("invalid arguments")
// Func represents a function registered by the Context.
// See its `buildMeta` and `call` internal methods.
type Func struct {
RegisterName string // the name of which this function is registered, for information only.
Raw interface{} // the Raw function, can be used for custom casting.
PersistenceArgs []interface{} // the persistence input arguments given on registration.
RegisterName string // the name of which this function is registered, for information only.
Raw any // the Raw function, can be used for custom casting.
PersistenceArgs []any // the persistence input arguments given on registration.
once sync.Once // guards build once, on first call.
// Available after the first call.
Meta *FuncMeta
}
func newFunc(name string, fn interface{}, persistenceArgs ...interface{}) *Func {
func newFunc(name string, fn any, persistenceArgs ...any) *Func {
return &Func{
RegisterName: name,
Raw: fn,
@@ -37,8 +37,8 @@ type FuncMeta struct {
HandlerWithErr func(*Context) error // when it's just a handler which returns an error.
RawFunc func() // when it's just a func.
RawFuncWithErr func() error // when it's just a func which returns an error.
RawFuncArgs func(...interface{})
RawFuncArgsWithErr func(...interface{}) error
RawFuncArgs func(...any)
RawFuncArgsWithErr func(...any) error
Value reflect.Value
Type reflect.Type
@@ -65,10 +65,10 @@ func (f *Func) buildMeta() {
case func() error:
f.Meta = &FuncMeta{RawFuncWithErr: fn}
return
case func(...interface{}):
case func(...any):
f.Meta = &FuncMeta{RawFuncArgs: fn}
return
case func(...interface{}) error:
case func(...any) error:
f.Meta = &FuncMeta{RawFuncArgsWithErr: fn}
return
}
@@ -119,7 +119,7 @@ func (f *Func) buildMeta() {
f.Meta = &meta
}
func (f *Func) call(ctx *Context, args ...interface{}) ([]reflect.Value, error) {
func (f *Func) call(ctx *Context, args ...any) ([]reflect.Value, error) {
f.once.Do(f.buildMeta)
meta := f.Meta

View File

@@ -34,7 +34,7 @@ var ErrNotSupported = errors.New("not supported")
// - UserPartial (a wrapper by SetUser)
type User interface {
// GetRaw should return the raw instance of the user, if supported.
GetRaw() (interface{}, error)
GetRaw() (any, error)
// GetAuthorization should return the authorization method,
// e.g. Basic Authentication.
GetAuthorization() (string, error)
@@ -60,12 +60,12 @@ type User interface {
// GetField should optionally return a dynamic field
// based on its key. Useful for custom user fields.
// Keep in mind that these fields are encoded as a separate JSON key.
GetField(key string) (interface{}, error)
GetField(key string) (any, error)
} /* Notes:
We could use a structure of User wrapper and separate interfaces for each of the methods
so they return ErrNotSupported if the implementation is missing it, so the `Features`
field and HasUserFeature can be omitted and
add a Raw() interface{} to return the underline User implementation too.
add a Raw() any to return the underline User implementation too.
The advandages of the above idea is that we don't have to add new methods
for each of the builtin features and we can keep the (assumed) struct small.
But we dont as it has many disadvantages, unless is requested.
@@ -95,7 +95,7 @@ type SimpleUser struct {
var _ User = (*SimpleUser)(nil)
// GetRaw returns itself.
func (u *SimpleUser) GetRaw() (interface{}, error) {
func (u *SimpleUser) GetRaw() (any, error) {
return u, nil
}
@@ -156,7 +156,7 @@ func (u *SimpleUser) GetToken() ([]byte, error) {
// GetField optionally returns a dynamic field from the `Fields` field
// based on its key.
func (u *SimpleUser) GetField(key string) (interface{}, error) {
func (u *SimpleUser) GetField(key string) (any, error) {
if u.Fields == nil {
return nil, ErrNotSupported
}
@@ -164,10 +164,10 @@ func (u *SimpleUser) GetField(key string) (interface{}, error) {
return u.Fields[key], nil
}
// UserMap can be used to convert a common map[string]interface{} to a User.
// UserMap can be used to convert a common map[string]any to a User.
// Usage:
//
// user := map[string]interface{}{
// user := map[string]any{
// "username": "kataras",
// "age" : 27,
// }
@@ -189,7 +189,7 @@ type UserMap Map
var _ User = UserMap{}
// GetRaw returns the underline map.
func (u UserMap) GetRaw() (interface{}, error) {
func (u UserMap) GetRaw() (any, error) {
return Map(u), nil
}
@@ -235,11 +235,11 @@ func (u UserMap) GetToken() ([]byte, error) {
// GetField returns the raw map's value based on its "key".
// It's not kind of useful here as you can just use the map.
func (u UserMap) GetField(key string) (interface{}, error) {
func (u UserMap) GetField(key string) (any, error) {
return u[key], nil
}
func (u UserMap) val(key string) interface{} {
func (u UserMap) val(key string) any {
isTitle := unicode.IsTitle(rune(key[0])) // if starts with uppercase.
if isTitle {
key = strings.ToLower(key)
@@ -333,7 +333,7 @@ type (
}
userGetField interface {
GetField(string) interface{}
GetField(string) any
}
// UserPartial is a User.
@@ -341,7 +341,7 @@ type (
// may or may not complete the whole User interface.
// See Context.SetUser.
UserPartial struct {
Raw interface{} `json:"raw"`
Raw any `json:"raw"`
userGetAuthorization `json:",omitempty"`
userGetAuthorizedAt `json:",omitempty"`
userGetID `json:",omitempty"`
@@ -356,7 +356,7 @@ type (
var _ User = (*UserPartial)(nil)
func newUserPartial(i interface{}) *UserPartial {
func newUserPartial(i any) *UserPartial {
if i == nil {
return nil
}
@@ -407,7 +407,7 @@ func newUserPartial(i interface{}) *UserPartial {
}
// GetRaw returns the original raw instance of the user.
func (u *UserPartial) GetRaw() (interface{}, error) {
func (u *UserPartial) GetRaw() (any, error) {
if u == nil {
return nil, ErrNotSupported
}
@@ -496,7 +496,7 @@ func (u *UserPartial) GetToken() ([]byte, error) {
// GetField should optionally return a dynamic field
// based on its key. Useful for custom user fields.
// Keep in mind that these fields are encoded as a separate JSON key.
func (u *UserPartial) GetField(key string) (interface{}, error) {
func (u *UserPartial) GetField(key string) (any, error) {
if v := u.userGetField; v != nil {
return v.GetField(key), nil
}

View File

@@ -17,7 +17,7 @@ import (
// It affects the view engine's filesystem resolver.
//
// This package-level variable can be modified on initialization.
var ResolveFS = func(fsOrDir interface{}) fs.FS {
var ResolveFS = func(fsOrDir any) fs.FS {
if fsOrDir == nil {
return noOpFS{}
}
@@ -101,7 +101,7 @@ func (f *httpFS) ReadDir(name string) ([]fs.DirEntry, error) {
// It affects the Application's API Builder's `HandleDir` method.
//
// This package-level variable can be modified on initialization.
var ResolveHTTPFS = func(fsOrDir interface{}) http.FileSystem {
var ResolveHTTPFS = func(fsOrDir any) http.FileSystem {
var fileSystem http.FileSystem
switch v := fsOrDir.(type) {
case string:

View File

@@ -131,7 +131,7 @@ type Handler = func(*Context)
// See `Handler` for more.
type Handlers = []Handler
func valueOf(v interface{}) reflect.Value {
func valueOf(v any) reflect.Value {
if val, ok := v.(reflect.Value); ok {
return val
}
@@ -142,7 +142,7 @@ func valueOf(v interface{}) reflect.Value {
// HandlerName returns the handler's function name.
// See `Context.HandlerName` method to get function name of the current running handler in the chain.
// See `SetHandlerName` too.
func HandlerName(h interface{}) string {
func HandlerName(h any) string {
pc := valueOf(h).Pointer()
fn := runtime.FuncForPC(pc)
name := fn.Name()
@@ -166,10 +166,10 @@ func HandlerName(h interface{}) string {
// or to determinate if end-developer
// called the same exactly Use/UseRouter/Done... API methods
// so framework can give a warning.
func HandlersNames(handlers ...interface{}) string {
func HandlersNames(handlers ...any) string {
if len(handlers) == 1 {
if hs, ok := handlers[0].(Handlers); ok {
asInterfaces := make([]interface{}, 0, len(hs))
asInterfaces := make([]any, 0, len(hs))
for _, h := range hs {
asInterfaces = append(asInterfaces, h)
}
@@ -188,14 +188,14 @@ func HandlersNames(handlers ...interface{}) string {
// HandlerFileLine returns the handler's file and line information.
// See `context.HandlerFileLine` to get the file, line of the current running handler in the chain.
func HandlerFileLine(h interface{}) (file string, line int) {
func HandlerFileLine(h any) (file string, line int) {
pc := valueOf(h).Pointer()
return runtime.FuncForPC(pc).FileLine(pc)
}
// HandlerFileLineRel same as `HandlerFileLine` but it returns the path
// corresponding to its relative based on the package-level "WorkingDir" variable.
func HandlerFileLineRel(h interface{}) (file string, line int) {
func HandlerFileLineRel(h any) (file string, line int) {
file, line = HandlerFileLine(h)
if relFile, err := filepath.Rel(WorkingDir, file); err == nil {
if !strings.HasPrefix(relFile, "..") {
@@ -209,13 +209,13 @@ func HandlerFileLineRel(h interface{}) (file string, line int) {
// MainHandlerName tries to find the main handler that end-developer
// registered on the provided chain of handlers and returns its function name.
func MainHandlerName(handlers ...interface{}) (name string, index int) {
func MainHandlerName(handlers ...any) (name string, index int) {
if len(handlers) == 0 {
return
}
if hs, ok := handlers[0].(Handlers); ok {
tmp := make([]interface{}, 0, len(hs))
tmp := make([]any, 0, len(hs))
for _, h := range hs {
tmp = append(tmp, h)
}

View File

@@ -7,8 +7,8 @@ import "golang.org/x/text/language"
type I18nReadOnly interface {
Tags() []language.Tag
GetLocale(ctx *Context) Locale
Tr(lang string, key string, args ...interface{}) string
TrContext(ctx *Context, key string, args ...interface{}) string
Tr(lang string, key string, args ...any) string
TrContext(ctx *Context, key string, args ...any) string
}
// Locale is the interface which returns from a `Localizer.GetLocale` method.
@@ -25,5 +25,5 @@ type Locale interface {
// Same as `Tag().String()` but it's static.
Language() string
// GetMessage should return translated text based on the given "key".
GetMessage(key string, args ...interface{}) string
GetMessage(key string, args ...any) string
}

View File

@@ -11,7 +11,7 @@ type Pool struct {
}
// New creates and returns a new context pool.
func New(newFunc func() interface{}) *Pool {
func New(newFunc func() any) *Pool {
return &Pool{pool: &sync.Pool{New: newFunc}}
}

View File

@@ -15,7 +15,7 @@ import (
// write an "application/problem+json" response.
//
// Read more at: https://github.com/kataras/iris/blob/main/_examples/routing/http-errors.
type Problem map[string]interface{}
type Problem map[string]any
// NewProblem retruns a new Problem.
// Head over to the `Problem` type godoc for more.
@@ -99,12 +99,12 @@ const (
// TempKey sets a temporary key-value pair, which is being removed
// on the its first get.
func (p Problem) TempKey(key string, value interface{}) Problem {
func (p Problem) TempKey(key string, value any) Problem {
return p.Key(problemTempKeyPrefix+key, value)
}
// GetTempKey returns the temp value based on "key" and removes it.
func (p Problem) GetTempKey(key string) interface{} {
func (p Problem) GetTempKey(key string) any {
key = problemTempKeyPrefix + key
v, ok := p[key]
if ok {
@@ -116,7 +116,7 @@ func (p Problem) GetTempKey(key string) interface{} {
}
// Key sets a custom key-value pair.
func (p Problem) Key(key string, value interface{}) Problem {
func (p Problem) Key(key string, value any) Problem {
p[key] = value
return p
}
@@ -277,20 +277,20 @@ type ProblemOptions struct {
// 300 * time.Second,
// "5m",
// 300
RetryAfter interface{}
RetryAfter any
// A function that, if specified, can dynamically set
// retry-after based on the request. Useful for ProblemOptions reusability.
// Should return time.Time, time.Duration, int64, int, float64 or string.
//
// Overrides the RetryAfter field.
RetryAfterFunc func(*Context) interface{}
RetryAfterFunc func(*Context) any
}
func parseDurationToSeconds(dur time.Duration) int64 {
return int64(math.Round(dur.Seconds()))
}
func (o *ProblemOptions) parseRetryAfter(value interface{}, timeLayout string) string {
func (o *ProblemOptions) parseRetryAfter(value any, timeLayout string) string {
// https://tools.ietf.org/html/rfc7231#section-7.1.3
// Retry-After = HTTP-date / delay-seconds
switch v := value.(type) {

View File

@@ -70,7 +70,7 @@ func (r *RequestParams) GetEntry(key string) memstore.Entry {
// Visit accepts a visitor which will be filled
// by the key-value params.
func (r *RequestParams) Visit(visitor func(key string, value string)) {
r.Store.Visit(func(k string, v interface{}) {
r.Store.Visit(func(k string, v any) {
visitor(k, fmt.Sprintf("%v", v)) // always string here.
})
}
@@ -227,7 +227,7 @@ func (r *RequestParams) GetIntUnslashed(key string) (int, bool) {
// The value is a function which accepts the parameter index
// and it should return the value as the parameter type evaluator expects it.
//
// i.e [reflect.TypeOf("string")] = func(paramIndex int) interface{} {
// i.e [reflect.TypeOf("string")] = func(paramIndex int) any {
// return func(ctx *Context) <T> {
// return ctx.Params().GetEntryAt(paramIndex).ValueRaw.(<T>)
// }
@@ -238,8 +238,8 @@ func (r *RequestParams) GetIntUnslashed(key string) (int, bool) {
// and parameter index based on the hero/mvc function added
// in order to support the MVC.HandleMany("GET", "/path/{ps}/{pssecond} /path/{ps}")
// when on the second requested path, the 'pssecond' should be empty.
var ParamResolvers = map[reflect.Type]func(paramIndex int) interface{}{
reflect.TypeOf(""): func(paramIndex int) interface{} {
var ParamResolvers = map[reflect.Type]func(paramIndex int) any{
reflect.TypeOf(""): func(paramIndex int) any {
return func(ctx *Context) string {
if ctx.Params().Len() <= paramIndex {
return ""
@@ -247,7 +247,7 @@ var ParamResolvers = map[reflect.Type]func(paramIndex int) interface{}{
return ctx.Params().GetEntryAt(paramIndex).ValueRaw.(string)
}
},
reflect.TypeOf(int(1)): func(paramIndex int) interface{} {
reflect.TypeOf(int(1)): func(paramIndex int) any {
return func(ctx *Context) int {
if ctx.Params().Len() <= paramIndex {
return 0
@@ -257,7 +257,7 @@ var ParamResolvers = map[reflect.Type]func(paramIndex int) interface{}{
return ctx.Params().GetEntryAt(paramIndex).ValueRaw.(int)
}
},
reflect.TypeOf(int8(1)): func(paramIndex int) interface{} {
reflect.TypeOf(int8(1)): func(paramIndex int) any {
return func(ctx *Context) int8 {
if ctx.Params().Len() <= paramIndex {
return 0
@@ -265,7 +265,7 @@ var ParamResolvers = map[reflect.Type]func(paramIndex int) interface{}{
return ctx.Params().GetEntryAt(paramIndex).ValueRaw.(int8)
}
},
reflect.TypeOf(int16(1)): func(paramIndex int) interface{} {
reflect.TypeOf(int16(1)): func(paramIndex int) any {
return func(ctx *Context) int16 {
if ctx.Params().Len() <= paramIndex {
return 0
@@ -273,7 +273,7 @@ var ParamResolvers = map[reflect.Type]func(paramIndex int) interface{}{
return ctx.Params().GetEntryAt(paramIndex).ValueRaw.(int16)
}
},
reflect.TypeOf(int32(1)): func(paramIndex int) interface{} {
reflect.TypeOf(int32(1)): func(paramIndex int) any {
return func(ctx *Context) int32 {
if ctx.Params().Len() <= paramIndex {
return 0
@@ -281,7 +281,7 @@ var ParamResolvers = map[reflect.Type]func(paramIndex int) interface{}{
return ctx.Params().GetEntryAt(paramIndex).ValueRaw.(int32)
}
},
reflect.TypeOf(int64(1)): func(paramIndex int) interface{} {
reflect.TypeOf(int64(1)): func(paramIndex int) any {
return func(ctx *Context) int64 {
if ctx.Params().Len() <= paramIndex {
return 0
@@ -289,7 +289,7 @@ var ParamResolvers = map[reflect.Type]func(paramIndex int) interface{}{
return ctx.Params().GetEntryAt(paramIndex).ValueRaw.(int64)
}
},
reflect.TypeOf(uint(1)): func(paramIndex int) interface{} {
reflect.TypeOf(uint(1)): func(paramIndex int) any {
return func(ctx *Context) uint {
if ctx.Params().Len() <= paramIndex {
return 0
@@ -297,7 +297,7 @@ var ParamResolvers = map[reflect.Type]func(paramIndex int) interface{}{
return ctx.Params().GetEntryAt(paramIndex).ValueRaw.(uint)
}
},
reflect.TypeOf(uint8(1)): func(paramIndex int) interface{} {
reflect.TypeOf(uint8(1)): func(paramIndex int) any {
return func(ctx *Context) uint8 {
if ctx.Params().Len() <= paramIndex {
return 0
@@ -305,7 +305,7 @@ var ParamResolvers = map[reflect.Type]func(paramIndex int) interface{}{
return ctx.Params().GetEntryAt(paramIndex).ValueRaw.(uint8)
}
},
reflect.TypeOf(uint16(1)): func(paramIndex int) interface{} {
reflect.TypeOf(uint16(1)): func(paramIndex int) any {
return func(ctx *Context) uint16 {
if ctx.Params().Len() <= paramIndex {
return 0
@@ -313,7 +313,7 @@ var ParamResolvers = map[reflect.Type]func(paramIndex int) interface{}{
return ctx.Params().GetEntryAt(paramIndex).ValueRaw.(uint16)
}
},
reflect.TypeOf(uint32(1)): func(paramIndex int) interface{} {
reflect.TypeOf(uint32(1)): func(paramIndex int) any {
return func(ctx *Context) uint32 {
if ctx.Params().Len() <= paramIndex {
return 0
@@ -321,7 +321,7 @@ var ParamResolvers = map[reflect.Type]func(paramIndex int) interface{}{
return ctx.Params().GetEntryAt(paramIndex).ValueRaw.(uint32)
}
},
reflect.TypeOf(uint64(1)): func(paramIndex int) interface{} {
reflect.TypeOf(uint64(1)): func(paramIndex int) any {
return func(ctx *Context) uint64 {
if ctx.Params().Len() <= paramIndex {
return 0
@@ -329,7 +329,7 @@ var ParamResolvers = map[reflect.Type]func(paramIndex int) interface{}{
return ctx.Params().GetEntryAt(paramIndex).ValueRaw.(uint64)
}
},
reflect.TypeOf(true): func(paramIndex int) interface{} {
reflect.TypeOf(true): func(paramIndex int) any {
return func(ctx *Context) bool {
if ctx.Params().Len() <= paramIndex {
return false
@@ -337,7 +337,7 @@ var ParamResolvers = map[reflect.Type]func(paramIndex int) interface{}{
return ctx.Params().GetEntryAt(paramIndex).ValueRaw.(bool)
}
},
reflect.TypeOf(time.Time{}): func(paramIndex int) interface{} {
reflect.TypeOf(time.Time{}): func(paramIndex int) any {
return func(ctx *Context) time.Time {
if ctx.Params().Len() <= paramIndex {
return unixEpochTime
@@ -351,7 +351,7 @@ var ParamResolvers = map[reflect.Type]func(paramIndex int) interface{}{
return v
}
},
reflect.TypeOf(time.Weekday(0)): func(paramIndex int) interface{} {
reflect.TypeOf(time.Weekday(0)): func(paramIndex int) any {
return func(ctx *Context) time.Weekday {
if ctx.Params().Len() <= paramIndex {
return time.Sunday
@@ -382,7 +382,7 @@ func ParamResolverByTypeAndIndex(typ reflect.Type, paramIndex int) (reflect.Valu
/* NO:
// This could work but its result is not exact type, so direct binding is not possible.
resolver := m.ParamResolver
fn := func(ctx *context.Context) interface{} {
fn := func(ctx *context.Context) any {
entry, _ := ctx.Params().GetEntry(paramName)
return resolver(entry)
}

View File

@@ -17,7 +17,7 @@ var Recorder = func(ctx *Context) {
ctx.Next()
}
var rrpool = sync.Pool{New: func() interface{} { return &ResponseRecorder{} }}
var rrpool = sync.Pool{New: func() any { return &ResponseRecorder{} }}
// AcquireResponseRecorder returns a new *AcquireResponseRecorder from the pool.
// Releasing is done automatically when request and response is done.

View File

@@ -127,7 +127,7 @@ type ResponseWriterWriteTo interface {
// | Response Writer Implementation |
// +------------------------------------------------------------+
var rpool = sync.Pool{New: func() interface{} { return &responseWriter{} }}
var rpool = sync.Pool{New: func() any { return &responseWriter{} }}
// AcquireResponseWriter returns a new *ResponseWriter from the pool.
// Releasing is done automatically when request and response is done.

View File

@@ -64,7 +64,7 @@ type RouteReadOnly interface {
// Property returns a specific property based on its "key"
// of this route's Party owner.
Property(key string) (interface{}, bool)
Property(key string) (any, bool)
// Sitemap properties: https://www.sitemaps.org/protocol.html

View File

@@ -10,7 +10,7 @@ import (
type ErrViewNotExist struct {
Name string
IsLayout bool
Data interface{}
Data any
}
// Error completes the `error` interface.
@@ -29,7 +29,7 @@ type ViewEngine interface {
// Load should load the templates from the given FileSystem.
Load() error
// ExecuteWriter should execute a template by its filename with an optional layout and bindingData.
ExecuteWriter(w io.Writer, filename string, layout string, bindingData interface{}) error
ExecuteWriter(w io.Writer, filename string, layout string, bindingData any) error
// Ext should return the final file extension (including the dot)
// which this view engine is responsible to render.
// If the filename extension on ExecuteWriter is empty then this is appended.
@@ -42,5 +42,5 @@ type ViewEngine interface {
// like {{ url }}, {{ urlpath }} and {{ tr }}.
type ViewEngineFuncer interface {
// AddFunc should adds a function to the template's function map.
AddFunc(funcName string, funcBody interface{})
AddFunc(funcName string, funcBody any)
}