kataras / kataras/iris

iris.Default() is not registering any view (or localization) but might be ok

Open
#1,774 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
25.6k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Hi,

First of all, thx for your awesome work with Iris. I've been working with other frameworks for a while and recently found out Iris. The developer XP is great. 👍

This is not really a bug or an issue since the `iris.Default()` func is not documented as registering a default view and localization folder. But... in the func comment I can read :

```
// Localization enabled on "./locales" directory
// and HTML templates on "./views" or "./templates" directory.
```

However, running this file :

```golang
package main

import "github.com/kataras/iris/v12"

func main() {
app := iris.Default()

app.Get("/", index)

app.Listen(":8080")
}

func index(ctx iris.Context) {
data := iris.Map{
"Title": "Page Title",
"FooterText": "Footer contents",
"Message": "Main contents",
}

ctx.ViewLayout("layouts/main")
ctx.View("index", data)
}
````

Produce this error :

```
Now listening on: http://localhost:8080
Application started. Press CMD+C to shut down.
[ERRO] 2021/06/06 19:13 view engine is missing, use `RegisterView`
```

I've seen you've been working on this `Default()` func recently and since the `12.2.0` version is still an alpha, I was wondering if it wasn't a good time to either implement the `RegisterView` or delete the comment.

In my point of view, it's quite a hard choice to register a view by default since the developer may not need to work with views.
Why not keeping the `Default()` setting up the log level, the access log, and the recovery mode? And maybe add a new `DefaultWebapp()` func which could register a view?

If you're ok with that, I'd be glad to help and submit a short PR.

Contributor guide

Open the contributing guide

Research direction

Start at iris.Default() and the RegisterView entry point, then compare the function comment with the documented behavior shown by the example. Done means resolving whether Default should register views and localization or whether its comment should be corrected, with the chosen behavior reflected consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.