kataras on master
Thanks @acdias for your kind do… (compare)
kataras on master
README: minor (compare)
kataras on master
fix bug: RWMutex not unlocked Merge pull request #1753 from o… (compare)
kataras on master
Thanks @rfunix and @liheyuan fo… (compare)
kataras on master
add Party.RemoveRoute method as… (compare)
kataras on master
add Party.RemoveRoute method as… (compare)
kataras on master
add Party.RemoveRoute method as… (compare)
kataras on master
Thanks @RainerGevers and @shado… (compare)
kataras on master
Thanks @knavels, @rxrw, @rbondi… (compare)
kataras on master
Happy Greek Independence Day! (compare)
kataras on master
Thanks @wofka72 for your kind d… (compare)
kataras on master
add CustomPathWordFunc Merge pull request #1746 from y… (compare)
kataras on master
bug fix #1741 add a tls.Config parameter for … Merge pull request #1742 from t… (compare)
On a CMS sort of site I think you have a database entry for every pages and one or more template types associated and generated dinamically.
Another solution is to generate a static site based on Hugo and Netlify CMS, that for simple CMS is what I use today. It’s faster and simple to deploy.
Hello @vuhoanglam,
The ctx.View
returns an error
. This error is always logged to your terminal screen (or log file) if the logger is not disabled.
If the application is running under debug log level (app.Logger().SetLevel("debug")
) then the client will receive the error text too but if not (default behavior) then it just returns the error the caller, so you can catch it.
Example Code:
<!-- ./view/fallback.html -->
<h1>Fallback view of {{.ViewRequested}}</h1>
package main
import (
"github.com/kataras/iris/v12"
)
const defaultViewName = "fallback"
func main() {
app := iris.New()
app.RegisterView(iris.HTML("./view", ".html"))
app.Get("/", index)
app.Listen(":8080")
}
func index(ctx iris.Context) {
var viewName = "blabla"
err := ctx.View(viewName)
if err != nil {
ctx.View(defaultViewName, iris.Map{
"ViewRequested": viewName,
})
}
}
I assume you just want to render something as 'fallback' - that you can do already as shown above.
Now, if you are asking if you can disable this log line of "template x does not exist" then it's a different thing. We can create a config field in order to disable that message :)
Hello @vuhoanglam, you can do it from the donate form, from https://iris-go.com. Thanks :heart: .
Yes you can name file routers. The HandleDir
method returns a slice of []*Route
. Each *Route
has a Name
property, just modify it to your preffered onces.
go get -u github.com/kataras/iris/v12@latest
so I ran that and it was successful. I built the executable again, re-ran, and I got the same warning/error. It asks me if I want to autofix it. I went for it, and I get [FTAL] 2021/02/05 02:18 autofix: replace import paths: open /tmp/foo/test: text file busy
. test
here is the executable that gave me this warning and asked me if I want to autofix. How can I fix it manually or workaround this issue?
$ ./test
You have installed an invalid version. Install with:
go get -u github.com/kataras/iris/v12@latest
If your Open Source project depends on that pre-go1.9 version please open an issue
at https://github.com/kataras/iris/issues/new and share your repository with us,
we will upgrade your project's code base to the latest version for free.
If you have a commercial project that you cannot share publically, please contact with
@kataras at https://chat.iris-go.com. Assistance will be provided to you and your colleagues
for free.
Run autofix? (Y/n): y
[INFO] 2021/02/05 02:18 Backup </tmp/foo> to </tmp/foo_irisbckp.zip>
[INFO] 2021/02/05 02:18 Updating...
[FTAL] 2021/02/05 02:18 autofix: replace import paths: open /tmp/foo/test: text file busy
app.HandleDir("/css", "./website/assets/css")
(the first input parameter now is an interface{} which can accept string
and http.FileSystem
, there is a third optional parameter which is the iris.DirOptions
- you can configure the static file server).
go get github.com/kataras/iris/v12@master
).
@kataras Still stuck in above issue unable to run grpc example .I am very new backend development. Tnx
here i am getting issue . if i try to change the port 443 to some thing else api won't work . if i request with 443 getting tls handshake fail issue
i followed https://github.com/kataras/iris/tree/master/_examples/mvc/grpc-compatible link
package main
import (
"log"
"time"
"github.com/kataras/iris/v12"
)
func main() {
app := iris.New()
app.Use(Filter())
booksAPI := app.Party("/books")
{
// GET: http://localhost:8080/books
booksAPI.Get("/", list)
// POST: http://localhost:8080/books
booksAPI.Post("/", create)
}
app.Listen(":8080")
}
// Book example.
type Book struct {
Title string `json:"title"`
}
func list(ctx iris.Context) {
books := []Book{
{"Mastering Concurrency in Go"},
{"Go Design Patterns"},
{"Black Hat Go"},
}
ctx.JSON(books)
// TIP: negotiate the response between server's prioritizes
// and client's requirements, instead of ctx.JSON:
// ctx.Negotiation().JSON().MsgPack().Protobuf()
// ctx.Negotiate(books)
ctx.StatusCode(403)
}
func Filter() iris.Handler {
return func(ctx iris.Context) {
t := time.Now()
// Set a shared variable between handlers
ctx.Values().Set("framework", "iris")
// before request
ctx.Next()
// after request
latency := time.Since(t)
log.Print(latency)
// access the status we are sending
status := ctx.GetStatusCode()
log.Println(status)
// How to set the status code according to the final result?
// e.g. if err != nil {
ctx.StatusCode(403)
}
}
func create(ctx iris.Context) {
var b Book
err := ctx.ReadJSON(&b)
// TIP: use ctx.ReadBody(&b) to bind
// any type of incoming data instead.
if err != nil {
ctx.StatusCode(iris.StatusInternalServerError)
return
}
println("Received Book: " + b.Title)
ctx.StatusCode(iris.StatusCreated)
}