Iris v14 is the first new major version since v12. The module path is github.com/kataras/iris/v14 and it requires Go 1.27 or later.
go get github.com/kataras/iris/v14@v14.0.0package main
import "github.com/kataras/iris/v14"
type Book struct {
Title string `json:"title"`
}
func main() {
app := iris.New()
app.Get("/books/{id:uuid}", func(ctx iris.Context) {
ctx.JSON(iris.Map{"id": ctx.Params().GetString("id")})
})
app.Post("/books", func(ctx iris.Context) {
book, ok := ctx.BindJSON[Book]()
if !ok {
return
}
ctx.StatusCode(iris.StatusCreated)
ctx.JSON(book)
})
app.Listen(":8080")
}ctx.BindJSON[Book]() is a generic method, which is why v14 needs Go 1.27. It decodes the body, runs Validate() error when the type has one, and answers the client itself when either step fails.
What is new
iris.NewBuilderassembles an application in one compile-checked chain: CORS, compression, access logging, a health endpoint, error mapping, services and API groups.- Typed request binding on generic methods (
ctx.BindJSON[T](),ctx.BindUpdate[T]()) replaces hand-written decode blocks. rest/errors: handlers report errors and one central map turns them into canonical, machine-readable responses. Internal details go to the server log and never to the client.- A dependency injection container is built in and replaces
hero. Constructors declare what they need,Initializerhooks run at startup and closers run at shutdown. - JSON runs on
encoding/json/v2. - Thirty-one built-in middleware, API keys being the newest. Sessions, cache, i18n, versioning and websocket now live under
middleware/. - Authentication at every scale: Basic Auth typed by your own user type, API keys, a generic JWT SDK, an identity server and an OAuth2 provider.
ai: renders and relays streamed model output over HTTP (text deltas, reasoning traces, tool-call fragments, usage). It is provider-agnostic and ships no vendor SDK.client: an HTTP client for calling other services under the same JSON rules the server side uses.- Views are a middleware.
middleware/viewholds a one-methodEngineinterface. The HTML, Django, Handlebars, Jet, Pug and Ace engines moved to iris-contrib/views, and kataras/blocks works as it is. - Server options:
app.Run(iris.ServerOptions{...})replacesiris.Addr,iris.TLSandiris.AutoTLS. ngrok tunneling is opt-in through a blank import ofcore/server/ngrok. - MVC controllers on Go generics, in
controller/mvc.
Upgrading from v12
Every removed v12 name fails at compile time, so the compiler's error list is your to-do list. MIGRATION.md maps each name to its replacement. It opens with a prompt that you can paste into a coding agent, which then does the mechanical part.
The replacements most applications meet first:
| v12 | v14 |
|---|---|
github.com/kataras/iris/v12
| github.com/kataras/iris/v14
|
iris.Party, app.Party(prefix)
| iris.Router, app.Router(prefix)
|
iris.Configuration, iris.With...
| iris.Options
|
iris.Addr, iris.TLS, iris.AutoTLS
| app.Run(iris.ServerOptions{...})
|
ctx.URLParam("q")
| ctx.Query().Get("q")
|
ctx.Params().Get("id")
| ctx.Params().GetString("id")
|
ctx.Header(k, v) to set, ctx.GetHeader(k) to read
| ctx.SetHeader(k, v) to set, ctx.Header(k) to read
|
app.RegisterView(engine), ctx.View(...)
| app.Use(view.Handler(engine)), view.Render(ctx, ...)
|
hero
| the built-in DI container |
middleware/logger
| middleware/accesslog
|
middleware/recover
| middleware/recovery
|
sessions, cache, websocket, i18n, view, versioning
| the same names under middleware/
|
mvc
| controller/mvc
|
x/errors, x/client, x/jsonx
| rest/errors, client, rest/types
|
Defaults that changed
The compiler does not flag these, so read them before you deploy:
- Session cookies are
SecureandSameSite=Lax. - JWT tokens are read from the
Authorizationheader only. - CORS no longer advertises credentials together with a wildcard origin.
ctx.SetCookiereplaces a cookie with the same name, path and domain, andctx.AddCookiedefaults toSameSite=Lax.- JSON is encoded and decoded by
encoding/json/v2.
MIGRATION.md explains each one, and lists the v12 bugs whose fixes change what you observe.
v12
Nothing changes for an application that imports github.com/kataras/iris/v12. That code stays on the v12 branch, and v12.2.12 is its latest release.
Documentation
- The Iris book: 24 chapters, free to read at iris-go.com/docs and to download as a PDF.
- TUTORIAL.md builds a Bookshelf service one idea at a time.
- 78 runnable examples in the order of the book.
- HISTORY.md lists every change in this release.
skill/iris: 21 reference documents written for coding agents.
Related repositories
- iris-contrib/views: the template engines.
- iris-contrib/middleware: 13 community middleware modules, updated for v14.
- kataras/blocks v0.1.0:
html/templatewith layouts and partials.
Found a problem? Open an issue.