+
diff --git a/_examples/dashboard-ar/views/partials/sidebar.html b/_examples/dashboard-ar/views/partials/sidebar.html
new file mode 100644
index 000000000..a24457b86
--- /dev/null
+++ b/_examples/dashboard-ar/views/partials/sidebar.html
@@ -0,0 +1,16 @@
+
diff --git a/_examples/dashboard-ar/views/routes.html b/_examples/dashboard-ar/views/routes.html
new file mode 100644
index 000000000..86a1f303c
--- /dev/null
+++ b/_examples/dashboard-ar/views/routes.html
@@ -0,0 +1,20 @@
+
+
+
+
+
الطريقة
+
المسار
+
المعالج
+
+
+
+ {{range .Routes}}
+
+
{{.Method}}
+
{{.Path}}
+
{{.Handler}}
+
+ {{end}}
+
+
+
diff --git a/aliases.go b/aliases.go
index bfb6e46ee..747af6b81 100644
--- a/aliases.go
+++ b/aliases.go
@@ -374,7 +374,7 @@ var (
// To skip HTTP Server logging for this type of warning:
// app.Listen/Run(..., iris.WithoutServerError(iris.ErrURLQuerySemicolon)).
AllowQuerySemicolons = func(ctx Context) {
- // clopy of net/http.AllowQuerySemicolons.
+ // copy of net/http.AllowQuerySemicolons.
r := ctx.Request()
if s := r.URL.RawQuery; strings.Contains(s, ";") {
r2 := new(http.Request)
@@ -486,7 +486,7 @@ var (
// StaticCache middleware for caching static files by sending the "Cache-Control" and "Expires" headers to the client.
// It accepts a single input parameter, the "cacheDur", a time.Duration that it's used to calculate the expiration.
//
- // If "cacheDur" <=0 then it returns the `NoCache` middleware instaed to disable the caching between browser's "back" and "forward" actions.
+ // If "cacheDur" <=0 then it returns the `NoCache` middleware instead to disable the caching between browser's "back" and "forward" actions.
//
// Usage: `app.Use(iris.StaticCache(24 * time.Hour))` or `app.Use(iris.StaticCache(-1))`.
// A middleware, which is a simple Handler can be called inside another handler as well, example:
@@ -662,7 +662,7 @@ const (
// HTTP status codes as registered with IANA.
// See: http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml.
-// Raw Copy from the future(tip) net/http std package in order to recude the import path of "net/http" for the users.
+// Raw Copy from the future(tip) net/http std package in order to reduce the import path of "net/http" for the users.
const (
StatusContinue = http.StatusContinue // RFC 7231, 6.2.1
StatusSwitchingProtocols = http.StatusSwitchingProtocols // RFC 7231, 6.2.2
@@ -835,13 +835,13 @@ func (cp *ContextPatches) SetCookieKVExpiration(patch time.Duration) {
// ResolveHTTPFS modifies the default way to resolve a filesystem by any type of value.
// It affects the Application's API Builder's `HandleDir` method.
-func (cp *ContextPatches) ResolveHTTPFS(patchFunc func(fsOrDir interface{}) http.FileSystem) {
+func (cp *ContextPatches) ResolveHTTPFS(patchFunc func(fsOrDir any) http.FileSystem) {
context.ResolveHTTPFS = patchFunc
}
// ResolveHTTPFS modifies the default way to resolve a filesystem by any type of value.
// It affects the view engine's filesystem resolver.
-func (cp *ContextPatches) ResolveFS(patchFunc func(fsOrDir interface{}) fs.FS) {
+func (cp *ContextPatches) ResolveFS(patchFunc func(fsOrDir any) fs.FS) {
context.ResolveFS = patchFunc
}
@@ -849,17 +849,17 @@ func (cp *ContextPatches) ResolveFS(patchFunc func(fsOrDir interface{}) fs.FS) {
type ContextWriterPatches struct{}
// JSON sets a custom function which runs and overrides the default behavior of the `Context#JSON` method.
-func (cwp *ContextWriterPatches) JSON(patchFunc func(ctx Context, v interface{}, options *JSON) error) {
+func (cwp *ContextWriterPatches) JSON(patchFunc func(ctx Context, v any, options *JSON) error) {
context.WriteJSON = patchFunc
}
// JSONP sets a custom function which runs and overrides the default behavior of the `Context#JSONP` method.
-func (cwp *ContextWriterPatches) JSONP(patchFunc func(ctx Context, v interface{}, options *JSONP) error) {
+func (cwp *ContextWriterPatches) JSONP(patchFunc func(ctx Context, v any, options *JSONP) error) {
context.WriteJSONP = patchFunc
}
// XML sets a custom function which runs and overrides the default behavior of the `Context#XML` method.
-func (cwp *ContextWriterPatches) XML(patchFunc func(ctx Context, v interface{}, options *XML) error) {
+func (cwp *ContextWriterPatches) XML(patchFunc func(ctx Context, v any, options *XML) error) {
context.WriteXML = patchFunc
}
@@ -869,7 +869,7 @@ func (cwp *ContextWriterPatches) Markdown(patchFunc func(ctx Context, v []byte,
}
// YAML sets a custom function which runs and overrides the default behavior of the `Context#YAML` method.
-func (cwp *ContextWriterPatches) YAML(patchFunc func(ctx Context, v interface{}, indentSpace int) error) {
+func (cwp *ContextWriterPatches) YAML(patchFunc func(ctx Context, v any, indentSpace int) error) {
context.WriteYAML = patchFunc
}
diff --git a/configuration.go b/configuration.go
index 848354d93..8a9f51dd0 100644
--- a/configuration.go
+++ b/configuration.go
@@ -588,7 +588,7 @@ func WithSitemap(startURL string) Configurator {
ctx.ContentType(context.ContentXMLHeaderValue)
ctx.Write(contentCopy) // nolint:errcheck
}
- if app.builded {
+ if app.built {
routes := app.CreateRoutes([]string{MethodGet, MethodHead, MethodOptions}, s.Path, handler)
for _, r := range routes {
diff --git a/iris.go b/iris.go
index fa0ece782..abc8b401c 100644
--- a/iris.go
+++ b/iris.go
@@ -84,7 +84,7 @@ type Application struct {
// view engine
view *view.View
// used for build
- builded bool
+ built bool
defaultMode bool
// OnBuild is a single function which
// is fired on the first `Build` method call.
@@ -98,7 +98,7 @@ type Application struct {
mu sync.RWMutex
// name is the application name and the log prefix for
// that Application instance's Logger. See `SetName` and `String`.
- // Defaults to IRIS_APP_NAME envrinoment variable otherwise empty.
+ // Defaults to IRIS_APP_NAME environment variable otherwise empty.
name string
// Hosts contains a list of all servers (Host Supervisors) that this app is running on.
//
@@ -128,7 +128,7 @@ func New() *Application {
logger := newLogger(app)
app.logger = logger
app.APIBuilder = router.NewAPIBuilder(logger)
- app.ContextPool = context.New(func() interface{} {
+ app.ContextPool = context.New(func() any {
return context.NewContext(app)
})
@@ -148,24 +148,6 @@ func Default() *Application {
app.logger.SetLevel("debug")
app.logger.Debugf(`Log level set to "debug"`)
- /* #2046.
- // Register the accesslog middleware.
- logFile, err := os.OpenFile("./access.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o600)
- if err == nil {
- // Close the file on shutdown.
- app.ConfigureHost(func(su *Supervisor) {
- su.RegisterOnShutdown(func() {
- logFile.Close()
- })
- })
-
- ac := accesslog.New(logFile)
- ac.AddOutput(app.logger.Printer)
- app.UseRouter(ac.Handler)
- app.logger.Debugf("Using <%s> to log requests", logFile.Name())
- }
- */
-
// Register the requestid middleware
// before recover so current Context.GetID() contains the info on panic logs.
app.UseRouter(requestid.New())
@@ -326,7 +308,7 @@ func (app *Application) Logger() *golog.Logger {
// IsDebug reports whether the application is running
// under debug/development mode.
// It's just a shortcut of Logger().Level >= golog.DebugLevel.
-// The same method existss as Context.IsDebug() too.
+// The same method exists as Context.IsDebug() too.
func (app *Application) IsDebug() bool {
return app.logger.Level >= golog.DebugLevel
}
@@ -339,21 +321,11 @@ func (app *Application) I18nReadOnly() context.I18nReadOnly {
// Validate validates a value and returns nil if passed or
// the failure reason if does not.
-func (app *Application) Validate(v interface{}) error {
+func (app *Application) Validate(v any) error {
if app.Validator == nil {
return nil
}
- // val := reflect.ValueOf(v)
- // if val.Kind() == reflect.Ptr && !val.IsNil() {
- // val = val.Elem()
- // }
-
- // if val.Kind() == reflect.Struct && val.Type() != timeType {
- // return app.Validator.Struct(v)
- // }
-
- // no need to check the kind, underline lib does it but in the future this may change (look above).
err := app.Validator.Struct(v)
if err != nil {
if !strings.HasPrefix(err.Error(), "validator: ") {
@@ -385,7 +357,7 @@ func Minify(ctx Context) {
w := ctx.Application().Minifier().ResponseWriter(ctx.ResponseWriter().Naive(), ctx.Request())
// Note(@kataras):
// We don't use defer w.Close()
- // because this response writer holds a sync.WaitGroup under the hoods
+ // because this response writer holds a sync.WaitGroup under the hood
// and we MUST be sure that its wg.Wait is called on request cancelation
// and not in the end of handlers chain execution
// (which if running a time-consuming task it will delay its resource release).
@@ -421,7 +393,7 @@ func (app *Application) RegisterView(viewEngine view.Engine) {
//
// Use context.View to render templates to the client instead.
// Returns an error on failure, otherwise nil.
-func (app *Application) View(writer io.Writer, filename string, layout string, bindingData interface{}) error {
+func (app *Application) View(writer io.Writer, filename string, layout string, bindingData any) error {
if !app.view.Registered() {
err := errors.New("view engine is missing, use `RegisterView`")
app.logger.Error(err)
@@ -628,15 +600,6 @@ func (app *Application) NewHost(srv *http.Server) *host.Supervisor {
return su
}
-// func (app *Application) OnShutdown(closers ...func()) {
-// for _,cb := range closers {
-// if cb == nil {
-// continue
-// }
-// RegisterOnInterrupt(cb)
-// }
-// }
-
// Shutdown gracefully terminates all the application's server hosts and any tunnels.
// Returns an error on the first failure, otherwise nil.
func (app *Application) Shutdown(ctx stdContext.Context) error {
@@ -678,7 +641,7 @@ func (app *Application) Shutdown(ctx stdContext.Context) error {
// app.Logger().Errorf("%s: %s", typ, err)
// })
func (app *Application) Build() error {
- if app.builded {
+ if app.built {
return nil
}
@@ -688,8 +651,7 @@ func (app *Application) Build() error {
}
}
- // start := time.Now()
- app.builded = true // even if fails.
+ app.built = true // even if fails.
// check if a prior app.Logger().SetLevel called and if not
// then set the defined configuration's log level.
@@ -794,9 +756,6 @@ func (app *Application) Build() error {
// app.RefreshRouter()
}
- // if end := time.Since(start); end.Seconds() > 5 {
- // app.logger.Debugf("Application: build took %s", time.Since(start))
-
return nil
}
@@ -1010,7 +969,7 @@ var (
ErrServerClosed = http.ErrServerClosed
// ErrURLQuerySemicolon is logged by the standard net/http server when
- // the request contains a semicolon (;) wihch, after go1.17 it's not used as a key-value separator character.
+ // the request contains a semicolon (;) which, after go1.17 it's not used as a key-value separator character.
//
// Ignore it by passing this error to the `iris.WithoutServerError` configurator
// on `Application.Run/Listen` method.
@@ -1216,7 +1175,9 @@ func (app *Application) tryStartTunneling() {
app.setVHost(publicAddr[strings.Index(publicAddr, "://")+3:])
directLog := []byte(fmt.Sprintf("• Public Address: %s\n", publicAddr))
- app.logger.Printer.Write(directLog) // nolint:errcheck
+ if _, err := app.logger.Printer.Write(directLog); err != nil {
+ app.logger.Errorf("failed to write public address log: %v", err)
+ }
})
})
}