Iris is an efficient and well-designed toolbox with robust set of features.
Write your own
perfect high-performance web applications
with unlimited potentials and portability.
- Godocs ⇒ https://godoc.org/gopkg.in/kataras/iris.v6
- Getting Started with Go+Iris ⇒ http://gopherbook.iris-go.com
- Navigate through community examples ⇒ https://github.com/iris-contrib/examples
- [./adaptors](https://github.com/kataras/iris/tree/v6/adaptors) and [./middleware](https://github.com/kataras/iris/tree/v6/middleware) contains examples of their usage.
- [HISTORY.md](https://github.com//kataras/iris/tree/v6/HISTORY.md) is your best friend, version migrations are released there.
Overview
-----------
```go
package main
import (
"gopkg.in/kataras/iris.v6"
"gopkg.in/kataras/iris.v6/adaptors/cors"
"gopkg.in/kataras/iris.v6/adaptors/httprouter"
"gopkg.in/kataras/iris.v6/adaptors/view"
)
func main() {
// Receives optional iris.Configuration{}, see ./configuration.go
// for more.
app := iris.New()
// Order doesn't matter,
// You can split it to different .Adapt calls.
// See ./adaptors folder for more.
app.Adapt(
// adapt a logger which prints all errors to the os.Stdout
iris.DevLogger(),
// adapt the adaptors/httprouter or adaptors/gorillamux
httprouter.New(),
// 5 template engines are supported out-of-the-box:
//
// - standard html/template
// - amber
// - django
// - handlebars
// - pug(jade)
//
// Use the html standard engine for all files inside "./views" folder with extension ".html"
view.HTML("./views", ".html"),
// Cors wrapper to the entire application, allow all origins.
cors.New(cors.Options{AllowedOrigins: []string{"*"}}))
// http://localhost:6300
// Method: "GET"
// Render ./views/index.html
app.Get("/", func(ctx *iris.Context) {
ctx.Render("index.html", iris.Map{"Title": "Page Title"}, iris.RenderOptions{"gzip": true})
})
// Group routes, optionally: share middleware, template layout and custom http errors.
userAPI := app.Party("/users", userAPIMiddleware).
Layout("layouts/userLayout.html")
{
// Fire userNotFoundHandler when Not Found
// inside http://localhost:6300/users/*anything
userAPI.OnError(404, userNotFoundHandler)
// http://localhost:6300/users
// Method: "GET"
userAPI.Get("/", getAllHandler)
// http://localhost:6300/users/42
// Method: "GET"
userAPI.Get("/:id", getByIDHandler)
// http://localhost:6300/users
// Method: "POST"
userAPI.Post("/", saveUserHandler)
}
// Start the server at 127.0.0.1:6300
app.Listen(":6300")
}
func userAPIMiddleware(ctx *iris.Context) {
// your code here...
println("Request: " + ctx.Path())
ctx.Next() // go to the next handler(s)
}
func userNotFoundHandler(ctx *iris.Context) {
// your code here...
ctx.HTML(iris.StatusNotFound, "
> Q: Why no `serverless`?
New web developers are so enthusiastic about the idea of `serverless` and `AWS`. Most of the experienced developers we already know that we shouldn't use these things for our critical parts of our application.
**`Serverless and AWS` Are Wonderful—Until They Go Wrong.** There was a flash-point (at 28 February of 2017) where the 'internet was offline' and most of the sites, including isitdownrightnow.com, were down or operated very slow! Why? Because of `serverless` and `AmazonS3`.
Please think twice before moving your code into `serverless`, **instead, use web frameworks that are created for servers that you control**, i.e Iris.
Proof of concept:
- [Washington Post](https://www.washingtonpost.com/news/the-switch/wp/2017/02/28/why-a-whole-slew-of-websites-are-suddenly-down-or-working-slowly)
- [CNN](http://money.cnn.com/2017/02/28/technology/amazon-web-services-outages/index.html)
- [CNET](https://www.cnet.com/news/no-the-internet-is-not-broken-amazon-web-services-is-just-having-issues/?ftag=COS-05-10-aa0a&linkId=34980800)
- [MIT Technology Review](https://www.technologyreview.com/s/603738/centralized-web-services-are-wonderful-until-they-go-wrong/?_ga=1.82562070.1263144274.1488319022)
- [GolangNews](https://golangnews.com/stories/1835-serverless-is-wonderfuluntil-they-go-wrong.)
Explore [these questions](http://support.iris-go.com/) and join to our [community chat][Chat]!
Testing
------------
The `httptest` package is a simple Iris helper for the httpexpect, a new library for End-to-end HTTP and REST API testing for Go.
You can find tests by navigating to the source code,
i.e:
- [context_test.go](https://github.com/kataras/iris/blob/v6/context_test.go)
- [handler_test.go](https://github.com/kataras/iris/blob/v6/handler_test.go)
- [policy_gorillamux_test.go](https://github.com/kataras/iris/blob/v6/policy_gorillamux_test.go)
- [policy_httprouter_test.go](https://github.com/kataras/iris/blob/v6/policy_httprouter_test.go)
- [policy_nativerouter_test.go](https://github.com/kataras/iris/blob/v6/policy_nativerouter_test.go)
- [policy_render_test.go](https://github.com/kataras/iris/blob/v6/policy_render_test.go)
- [policy_sessions_test.go](https://github.com/kataras/iris/blob/v6/policy_sessions_test.go)
- [response_writer_test.go](https://github.com/kataras/iris/blob/v6/response_writer_test.go)
- [route_test.go](https://github.com/kataras/iris/blob/v6/route_test.go)
- [status_test.go](https://github.com/kataras/iris/blob/v6/status_test.go)
- [transaction_test.go](https://github.com/kataras/iris/blob/v6/transaction_test.go)
A simple test is located to [./httptest/_example/main_test.go](https://github.com/kataras/iris/blob/v6/httptest/_example/main_test.go)
httpexpect's repository has some Iris examples too:
- https://github.com/gavv/httpexpect/blob/master/_examples/iris.go (without `httptest` package)
- https://github.com/gavv/httpexpect/blob/master/_examples/iris_test.go (without `httptest` package)
Read more about httpexpect [here](https://github.com/gavv/httpexpect).
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 is faster than nginx itself.
Iris does not force you to use any specific ORM or template engine. Iris is routerless which means you can adapt any router you like, [httprouter](https://github.com/kataras/iris/blob/v6/adaptors/httprouter/_example/main.go) is the fastest, [gorillamux](https://github.com/kataras/iris/blob/v6/adaptors/gorillamux/_example/main.go) has more features. With support for the most used template engines (5), you can quickly craft the perfect application.
People & Support
------------
The author of Iris is [@kataras](https://github.com/kataras).
The Success of Iris belongs to YOU with your bug reports and feature requests that made this Framework so Unique.
#### Who is kataras?
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.
- Star the project, will help you to follow the upcoming features.
- [Donate](https://github.com/kataras/iris/blob/master/DONATIONS.md), if you can afford any cost.
- Write an article about Iris or even post a Tweet.
- **Do Pull Requests on the [iris-contrib](https://github.com/iris-contrib)** organisation's repositories, like [book](https://github.com/iris-contrib/gitbook), [examples](https://github.com/iris-contrib/examples) and to [gopherbook](http://gopherbook.iris-go.com/).
If you are interested in contributing to the Iris project, please see the document [CONTRIBUTING](https://github.com/kataras/iris/blob/master/.github/CONTRIBUTING.md).
Contact
------------
Besides the fact that we have a [community chat][Chat] for questions or reports and ideas, [stackoverflow](http://stackoverflow.com/) section for generic go+iris questions and the [iris support](http://support.iris-go.com) for bug reports and feature requests, you can also contact with me, as a person who is always open to help you:
- [Twitter](https://twitter.com/MakisMaropoulos)
- [Facebook](https://facebook.com/kataras.gopher)
- [Linkedin](https://www.linkedin.com/in/gerasimos-maropoulos)
Versioning
------------
Current: **v6**, code-named as "√Νεxτ"
v5: https://github.com/kataras/iris/tree/5.0.0
License
------------
Unless otherwise noted, the source files are distributed
under the MIT License found in the [LICENSE file](LICENSE).
Note that some optional components that you may use with Iris requires
different license agreements.
TODO
------------
- [ ] Refactor the [Examples](https://github.com/iris-contrib/examples) to be align with the latest version
- [ ] Upgrade [GitBook](https://docs.iris-go.com) for the latest release
- [x] Add some missing tests from the previous version and find a way to share these end-to-end tests accross the adaptors and the root
- [ ] Replace http://iris-go.com content to something more fancy, as suggested [here](https://github.com/kataras/iris/issues/613)
- [x] Make a table list of the most famous middleware(s) with their descriptions, in order to help new Gophers find what they're looking for
Iris is a Community-Driven project waiting for your [feature requests](http://support.iris-go.com/t/feature-request)!
[Chat]: https://kataras.rocket.chat/channel/iris