Iris
Iris is an efficient and well-designed, cross-platform, web framework with robust set of features.
Build your own high-performance web applications and APIs powered by unlimited potentials and portability.
What you say about Iris ✌
If you're coming from Node.js world, this is the expressjs equivalent for the Go Programming Language.
Legends ♡
Juan Sebastián Suárez Valencia donated 20 EUR at September 11 of 2016
Bob Lee donated 20 EUR at September 16 of 2016
Celso Luiz donated 50 EUR at September 29 of 2016
Ankur Srivastava donated 20 EUR at October 2 of 2016
Damon Zhao donated 20 EUR at October 21 of 2016
exponity - consulting & digital transformation donated 30 EUR at November 4 of 2016
Thomas Fritz donated 25 EUR at Jenuary 8 of 2017
Thanos V. donated 20 EUR at Jenuary 16 of 2017
George Opritescu donated 20 EUR at February 7 of 2017
Lex Tang donated 20 EUR at February 22 of 2017
Conrad Steenberg donated 25 EUR at March 23 of 2017
Feature Overview
- Focus on high performance
- Automatically install and serve certificates from https://letsencrypt.org
- Robust routing and middleware ecosystem
- Build RESTful APIs
- Choose your favorite routes' path syntax between httprouter and gorillamux
- Request-Scoped Transactions
- Group API's and subdomains with wildcard support
- Body binding for JSON, XML, Forms, can be extended to use your own custom binders
- More than 50 handy functions to send HTTP responses
- View system: supporting more than 6+ template engines, with prerenders. You can still use your favorite
- Define virtual hosts and (wildcard) subdomains with path level routing
- Graceful shutdown
- Limit request body
- Localization i18N
- Serve static files
- Cache
- Log requests
- Customizable format and output for the logger
- Customizable HTTP errors
- Compression (Gzip)
- 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
- Highly scalable rich content render (Markdown, JSON, JSONP, XML...)
- Websocket-only API similar to socket.io
- Hot Reload on source code changes
- Typescript integration + Web IDE
- Checks for updates at startup
- Highly customizable
- Feels like you used iris forever, thanks to its Fluent API
- And many others...
Table of Contents
Installation
The only requirement is the Go Programming Language, at least 1.8
$ go get gopkg.in/kataras/iris.v6
Overview
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() {
app := iris.New()
app.Adapt(
iris.DevLogger(),
httprouter.New(),
view.HTML("./views", ".html"),
cors.New(cors.Options{AllowedOrigins: []string{"*"}}))
app.Get("/", func(ctx *iris.Context) {
ctx.Render("index.html", iris.Map{"Title": "Page Title"}, iris.RenderOptions{"gzip": true})
})
userAPI := app.Party("/users", userAPIMiddleware).
Layout("layouts/userLayout.html")
{
userAPI.OnError(404, userNotFoundHandler)
userAPI.Get("/", getAllHandler)
userAPI.Get("/:id", getByIDHandler)
userAPI.Post("/", saveUserHandler)
}
app.Listen(":6300")
}
func userAPIMiddleware(ctx *iris.Context) {
println("Request: " + ctx.Path())
ctx.Next()
}
func userNotFoundHandler(ctx *iris.Context) {
ctx.HTML(iris.StatusNotFound, "<h1> User page not found </h1>")
}
func getAllHandler(ctx *iris.Context) {
}
func getByIDHandler(ctx *iris.Context) {
userID, _ := ctx.ParamInt("id")
user := userRepo.GetByID(userID)
ctx.JSON(iris.StatusOK, user)
}
func saveUserHandler(ctx *iris.Context) {
}
Reload on source code changes
$ go get -u github.com/kataras/rizla
$ cd $GOPATH/src/mywebapp
$ rizla main.go
Reload templates on each incoming request
app.Adapt(view.HTML("./views", ".html").Reload(true))
FAQ & Documentation
-
Getting Started with Go+Iris
-
Official small but practical examples
-
Navigate through community examples too
-
Creating A URL Shortener Service Using Go, Iris, and Bolt
-
Godocs for deep documentation
-
HISTORY.md is your best friend, version migrations are released there
I'll be glad to talk with you about your awesome feature requests,
open a new discussion, you will be heard!
Support
- :star: the project, will help you to follow the upcoming features
- Donate, will help me to continue
- Post a feature request or report a bug, will help all of us to build a better web, together
- :earth_americas: post an article or tweet and share it with your neighbor
Buy me a cup of coffee?
Iris is free and open source but developing it has taken thousands of hours of my time and a large part of my sanity. If you feel this web framework useful to you, it would go a great way to ensuring that I can afford to take the time to continue to develop it.
I spend all my time in the construction of Iris, therefore I have no income value.
Feel free to send any amount through paypal
Please check your e-mail after your donation.
Thanks for your gratitude and finance help ♡
Third Party Middleware
Iris has its own middleware form of func(ctx *iris.Context)
but it's also compatible with all net/http
middleware forms using iris.ToHandler, i.e Negroni's middleware form of func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
.
Here is a small list of Iris compatible middleware, I'm sure you can find more:
Feel free to put up a PR your middleware!
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:
A simple test is located to ./_examples/advanced/httptest/main_test.go
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 is the fastest, gorillamux has more features. With support for the most used template engines (5), you can quickly craft the perfect application.
People
The author of Iris is @kataras.
However the real Success of Iris belongs to you with your bug reports and feature requests that made this Framework so Unique.
Contact
Besides the fact that we have a community chat for questions or reports and ideas, stackoverflow section for generic go+iris questions and the iris support for bug reports and feature requests, you can also contact with me, as a person who is always open to help you:
License
Unless otherwise noted, the source files are distributed
under the MIT License found in the LICENSE file.
Note that some optional components that you may use with Iris requires
different license agreements.