The fastest web framework for Go.
$ cat test_json.go
package main
import (
"github.com/kataras/iris"
)
func main() {
// render JSON
iris.Get("/hi_json", func(c *iris.Context) {
c.JSON(iris.StatusOK, iris.Map{
"Name": "Iris",
"Born": "13 March 2016",
"Stars": 2440,
})
})
iris.Listen(":8080")
}
Learn about configuration and render.
$ cat test_party.go
package main
import (
"github.com/kataras/iris"
"github.com/kataras/iris/middleware/logger"
)
func main() {
// logger middleware
log := logger.New(iris.Logger)
// group routes by path prefix and middleware sharing
group := iris.Party("/users", log)
{
group.Get("/", func(c *iris.Context) {
// return all users or render a template
})
group.Get("/:userID", func(c *iris.Context) {
// return a user with ID `c.Param("userID")`
})
group.Delete("/:userID", func(c *iris.Context) {
//delete a user with ID `c.Param("userID")`
})
}
// using static subdomains
subdomain := iris.Party("account.", log, myAuthMiddleware).Layout("layouts/subdomain.html")
{
subdomain.Get("/", func(c *iris.Context) {
// render a template with a context of {username: "myusername"}
c.Render("account/index.html", iris.Map{ // we can also use a struct
"username": c.Session().GetString("username"),
})
})
subdomain.Post("/edit", func(c *iris.Context) {
//...
})
}
// using dynamic subdomains
dynamicSub := iris.Party("*.")
{
// middleware on route, called before the final handler
dynamicSub.Get("/", log, func(c *iris.Context) {
c.Write("Hello from subdomain: %s", c.Subdomain())
})
}
iris.Listen(":8080")
}
// using high level sessions inside a custom middleware
func myAuthMiddleware(c *iris.Context) {
s := c.Session()
if s.GetString("username") == "myusername" && s.GetString("password") == "mypassword" {
c.Next()
} else {
c.EmitError(iris.StatusUnauthorized)
}
}
Learn about named parameters, parties and subdomains.
Installation
The only requirement is Go 1.6
$ go get -u github.com/kataras/iris/iris
If you are connected to the Internet through China click here
FAQ
You can find answers by exploring these questions.
Features
- Focus on high performance
- Robust routing & static, wildcard subdomains
- View system supporting 5+ template engines
- Highly scalable Websocket API with custom events
- Sessions support with GC, memory & redis providers
- Middlewares & Plugins were never be easier
- Full REST API
- Custom HTTP Errors
- Typescript compiler + Browser editor
- Content negotiation & streaming
- Transport Layer Security
- Reload on source code changes
- and much more
Docs & Community
If you'd like to discuss this package, or ask questions about it, feel free to
Open debates
TIP Be sure to read the history for Migrating from 2.x to 3.x.
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.
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 suite aims to compare the whole HTTP request processing between Go web frameworks.
Please click here to view all detailed benchmarks.
Testing
Iris suggests you to use this new suite to test your API. Httpexpect supports fasthttp & Iris after recommandation. Its author is very active so I believe its a promising library. You can view examples here and here.
Versioning
Current: v3.0.0-rc.2
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
for the next release 'v3'
- Dynamic/Wildcard subdomains.
- Create server & client side (js) library for .on('event', func action(...)) / .emit('event')... (like socket.io but supports only websocket).
- Find and provide support for the most stable template engine and be able to change it via the configuration, keep html/templates support.
- Extend, test and publish to the public the Iris' cmd.
- Route naming and html url func, requested here.
If you're willing to donate click here
People
A big thanks goes to all people who help building this framework with feature-requests, bug reports and more!
The author of Iris is @kataras.
License
This project is licensed under the Apache License 2.0.
License can be found here.