Iris
Iris is a fast, simple and efficient micro web framework for Go. It provides a beautifully expressive and easy to use foundation for your next website, API, or distributed app.
📑 Table of contents
🚀 Installation
The only requirement is the Go Programming Language, at least version 1.8
$ go get -u github.com/kataras/iris
iris takes advantage of the vendor directory feature. You get truly reproducible builds, as this method guards against upstream renames and deletes.
package main
import (
"github.com/kataras/iris"
"github.com/kataras/iris/context"
)
func main() {
app := iris.New()
app.RegisterView(iris.HTML("./templates", ".html"))
app.Get("/", func(ctx context.Context) {
ctx.ViewData("message", "Hello world!")
ctx.View("hello.html")
})
app.Run(iris.Addr(":8080"))
}
<html>
<head>
<title>Hello Page</title>
</head>
<body>
<h1>{{.message}}</h1>
</body>
</html>
$ go run main.go
> Now listening on: http://localhost:8080
> Application started. Press CTRL+C to shut down.
Hello World with Go 1.9
If you've installed Go 1.9 then you can omit the github.com/kataras/iris/context
package from the imports statement.
package main
import "github.com/kataras/iris"
func main() {
app := iris.New()
app.RegisterView(iris.HTML("./templates", ".html"))
app.Get("/", func(ctx iris.Context) {
ctx.ViewData("message", "Hello world!")
ctx.View("hello.html")
})
app.Run(iris.Addr(":8080"))
}
We expect Go version 1.9 to be released in August, however you can install Go 1.9 RC1 today.
Installing Go 1.9rc1
- Go to https://golang.org/dl/#go1.9rc1
- Download a compatible, with your OS, archive or executable, i.e
go1.9rc1.windows-amd64.zip
- Unzip the contents of
go1.9rc1.windows-amd64.zip
folder to your $GOROOT, i.e C:\Go
or just execute the executable you've just download - Open a terminal and execute
go version
, it should output the go1.9rc1 version, i.e:
C:\Users\kataras>go version
go version go1.9rc1 windows/amd64
Why a new web framework
Why
Go is a great technology stack for building scalable, web-based, back-end systems for web
applications.
When you think about building web applications and web APIs, or simply building HTTP servers in Go, does your mind go to the standard net/http package?
Then you have to deal with some common situations like dynamic routing (a.k.a parameterized), security and authentication, real-time communication and many other issues that net/http doesn't solve.
The net/http package is not complete enough to quickly build well-designed back-end web systems. When you realize this, you might be thinking along these lines:
- Ok, the net/http package doesn't suit me, but there are so many frameworks, which one will work for me?!
- Each one of them tells me that it is the best. I don't know what to do!
The truth
I did some deep research and benchmarks with 'wrk' and 'ab' in order to choose which framework would suit me and my new project. The results, sadly, were really disappointing to me.
I started wondering if golang wasn't as fast on the web as I had read... but, before I let Golang go and continued to develop with nodejs, I told myself:
'Makis, don't lose hope, give at least a chance to Golang. Try to build something totally new without basing it off the "slow" code you saw earlier; learn the secrets of this language and make others follow your steps!'.
These are the words I told myself that day [13 March 2016].
The same day, later the night, I was reading a book about Greek mythology. I saw an ancient goddess' name and was inspired immediately to give a name to this new web framework (which I had already started writing) - Iris.
I'm still here because Iris has succeed in being the fastest go web framework
iris is easy, it has a familiar API while in the same has far more features than Gin or Martini.
You own your code —it will never generate (unfamiliar) code for you, like Beego, Revel and Buffalo do.
It's not just-another-router but its overall performance is equivalent with something like httprouter.
Unlike fasthttp, iris provides full HTTP/2 support for free.
Compared to the rest open source projects, this one is very active and you get answers almost immediately.
🔥 Hot Features
- Focus on high performance
- Easy Fluent API
- Highly customizable
- Robust routing and middleware ecosystem
- Build RESTful APIs with iris unique expressionist path interpreter
- Dynamic path parameterized or wildcard routes are not conflict with static routes
- Remove trailing slash from the URL with option to redirect
- Virtual hosts and subdomains made easy
- Group API's and static or even dynamic subdomains
net/http
and negroni-like
handlers are compatible via iris.FromStd
- Register custom handlers for any HTTP error
- Transactions and rollback when you need it
- Cache the response when you need it
- A single function to serve your embedded assets, always compatible with
go-bindata
- HTTP to HTTPS
- HTTP to HTTPS WWW
- learn the reasons that differ from what you've seen so far
- Context
- Highly scalable rich content render (Markdown, JSON, JSONP, XML...)
- Body binders and handy functions to send HTTP responses
- Limit request body
- Serve static resources or embedded assets
- Localization i18N
- Compression (Gzip is built'n)
- Authentication
- Basic Authentication
- OAuth, OAuth2 supporting 27+ popular websites
- JWT
- Server
- Automatically install and serve certificates from https://letsencrypt.org when serving via TLS
- Gracefully shutdown by-default
- Register on shutdown, error or interrupt events
- Attach more than one server, fully compatible with
net/http#Server
- View system: supporting 5 template engines. Fully compatible with
html/template
- HTTP Sessions library [you can still use your favorite if you want to]
- Websocket library, its API similar to socket.io [you can still use your favorite if you want to]
- Hot Reload on source code changes*
- Typescript integration + Web IDE
- And many other things that will surprise you
📖 Learn
The iris philosophy is to provide robust tooling for HTTP, making it a great solution for single page applications, web sites, hybrids, or public HTTP APIs. Keep note that, today, iris is faster than apache+nginx itself.
iris does not force you to use any specific ORM. With support for the most popular template engines, websocket server and a fast sessions manager you can quickly craft your perfect application.
The awesome iris community is always adding new examples, _examples is a great place to get started!
Read the godocs for a better understanding.
Join the welcoming community of fellow iris developers in rocket.chat
- Post a feature request or report a bug
- :star: and watch the public repository, will keep you up to date
- :earth_americas: publish an article or share a tweet about your personal experience with iris.
The most useful community repository for iris developers is the
iris-contrib/middleware which contains some HTTP handlers that can help you finish a lot of your tasks even easier. Feel free to push your own middleware there!
$ go get -u github.com/iris-contrib/middleware/...
📈 One and a half years with You...
- 7210 github stars
- 766 github forks
- 1m total views at its documentation
- ~800$ at donations (there're a lot for a golang open-source project, thanks to you)
- ~554 reported bugs fixed
- ~30 community feature requests have been implemented
Thank You for your trust!
📌 Version
Current: 8.2.1
Each new release is pushed to the master. It stays there until the next version. When a next version is released then the previous version goes to its own branch with gopkg.in
as its import path (and its own vendor folder), in order to keep it working "for-ever".
Changelog of the current version can be found at the HISTORY file.
Should I upgrade my iris?
Developers are not forced to use the latest iris version, they can use any version in production, they can update at any time they want.
Testers should upgrade immediately, if you're willing to use iris in production you can wait a little more longer, transaction should be as safe as possible.
Where can I find older versions?
Previous versions can be found at releases page.
😃 Get Hired
Below you'll find a list of open positions that require at least experience with the Iris web framework.
Employers that are looking for briliant Software Engineers with good experience on Go Programming Language and Iris can put their startup's or company's name here or, if privacy is the key, contact with us to suggest some good and well-tested freelancers that suits your needs.
🥇 People
The original author of iris is Gerasimos Maropoulos
The current lead maintainer is Bill Qeras, Jr.
List of all contributors
Help this project to continue deliver awesome and unique features with the higher code quality as possible