17 KiB
The fastest backend web framework for Go.
Easy to learn, while it's highly customizable.
Ideally suited for both experienced and novice Developers.
Quick Look
package main
import "github.com/kataras/iris"
func main() {
// serve static files, just a fav here
iris.Favicon("./favicon.ico")
// handle "/" - HTTP METHOD: "GET"
iris.Get("/", func(ctx *iris.Context) {
ctx.Render("index.html", nil)
})
iris.Get("/login", func(ctx *iris.Context) {
ctx.Render("login.html", iris.Map{"Title": "Login Page"})
})
// handle "/login" - HTTP METHOD: "POST"
iris.Post("/login", func(ctx *iris.Context) {
secret := ctx.PostValue("secret")
ctx.Session().Set("secret", secret)
ctx.Redirect("/user")
})
// handle websocket connections
iris.Config.Websocket.Endpoint = "/mychat"
iris.Websocket.OnConnection(func(c iris.WebsocketConnection) {
c.Join("myroom")
c.On("chat", func(message string){
c.To("myroom").Emit("chat", "From "+c.ID()+": "+message)
})
})
// serve requests at http://localhost:8080
iris.Listen(":8080")
}
What's inside?
- Focus on high performance
- Automatically install TLS certificates from https://letsencrypt.org
- Robust routing and middleware ecosystem
- Define virtual hosts and (wildcard) subdomains with path level routing
- Graceful shutdown
- Limit request body
- I18N
- Serve static files
- Log requests
- Gzip response
- Authentication
- OAuth, OAuth2 supporting 27+ popular websites
- JWT
- Basic Authentication
- HTTP Sessions
- Add / Remove trailing slash from the URL with option to redirect
- Redirect requests
- HTTP to HTTPS
- HTTP to HTTPS WWW
- HTTP to HTTPS non WWW
- Non WWW to WWW
- WWW to non WWW
- View system supporting more than six template engines
- Highly scalable rich render (Markdown, JSON, JSONP, XML...)
- Websocket API similar to socket.io
- Hot Reload
- Typescript integration + Web IDE
- Checks for updates at startup
Getting Started
Installation
The only requirement is the Go Programming Language, at least v1.7.
$ go get -u github.com/kataras/iris/iris
If you have installation issues or you are connected to the Internet through China please, click here.
Need help?
-
The most important is to read the practical guide.
-
Explore & download the examples.
-
HISTORY.md file is your best friend.
FAQ
Explore these questions or navigate to the community chat.
Support
Hi, my name is Gerasimos Maropoulos and I'm the author of this project, let me put a few words about me.
I started to design iris the night of the 13 March 2016, some weeks later, iris started to became famous and I have to fix many issues and implement new features, but I didn't have time to work on Iris because I had a part time job and the (software engineering) colleague which I studied.
I wanted to make iris' users proud of the framework they're using, so I decided to interrupt my studies and colleague, two days later I left from my part time job also.
Today I spend all my days and nights coding for Iris, and I'm happy about this, therefore I have zero incoming value.
- ⭐ the project
- Donate
- 🌎 spread the word
- Contribute to the project
Name | Description | Usage |
---|---|---|
JSON | JSON Serializer (Default) | example 1,example 2, book section |
JSONP | JSONP Serializer (Default) | example 1,example 2, book section |
XML | XML Serializer (Default) | example 1,example 2, book section |
Markdown | Markdown Serializer (Default) | example 1,example 2, book section |
Text | Text Serializer (Default) | example 1, book section |
Binary Data | Binary Data Serializer (Default) | example 1, book section |
HTML/Default Engine | HTML Template Engine (Default) | example , book section |
Django Engine | Django Template Engine | example , book section |
Pug/Jade Engine | Pug Template Engine | example , book section |
Handlebars Engine | Handlebars Template Engine | example , book section |
Amber Engine | Amber Template Engine | example , book section |
Markdown Engine | Markdown Template Engine | example , book section |
Basicauth Middleware | HTTP Basic authentication | example 1, example 2, book section |
JWT Middleware | JSON Web Tokens | example , book section |
Cors Middleware | Cross Origin Resource Sharing W3 specification | how to use |
Secure Middleware | Facilitates some quick security wins | example |
I18n Middleware | Simple internationalization | example, book section |
Recovery Middleware | Safety recover the station from panic | example |
Logger Middleware | Logs every request | example, book section |
Profile Middleware | Http profiling for debugging | example |
Editor Plugin | Alm-tools, a typescript online IDE/Editor | book section |
Typescript Plugin | Auto-compile client-side typescript files | book section |
OAuth,OAuth2 Plugin | User Authentication was never be easier, supports >27 providers | example, book section |
Iris control Plugin | Basic (browser-based) control over your Iris station | example, book section |
Philosophy
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 has the clostest performance to the nginx.
Iris does not force you to use any specific ORM or template engine. With support for the most used template engines, you can quickly craft the perfect application.
Benchmarks
This Benchmark test aims to compare the whole HTTP request processing between Go web frameworks.
The results have been updated on July 21, 2016
Testing
I recommend writing your API tests using this new library, httpexpect which supports Iris and fasthttp now, after my request here. You can find Iris examples here, here and here.
Versioning
Current: v4.4.3
Iris is an active project
Read more about Semantic Versioning 2.0.0
- http://semver.org/
- https://en.wikipedia.org/wiki/Software_versioning
- https://wiki.debian.org/UpstreamGuide#Releases_and_Versions
Todo
Iris is a Community-Driven Project, waiting for your suggestions and feature requests!
People
The big thanks goes to all people who help building this framework with feature-requests & bug reports!
The author of Iris is @kataras. If you're willing to donate, feel free to navigate to the DONATIONS PAGE.
Contributing
If you are interested in contributing to the Iris project, please see the document CONTRIBUTING.
License
This project is licensed under the MIT License, Copyright (c) 2016 Gerasimos Maropoulos.