[![Black Lives Matter](https://iris-go.com/images/blacklivesmatter_banner.png)](https://support.eji.org/give/153413/#!/donation/checkout) > This is the under-**development branch**. Stay tuned for the upcoming release [v12.2.0](HISTORY.md#Next). Looking for a stable release? Head over to the [v12.1.8 branch](https://github.com/kataras/iris/tree/v12.1.8) instead. > > ![](https://iris-go.com/images/cli.png) Try the official [Iris Command Line Interface](https://github.com/kataras/iris-cli) today! # Iris Web Framework [![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/kataras/iris) [![view examples](https://img.shields.io/badge/examples%20-173-a83adf.svg?style=for-the-badge&logo=go)](https://github.com/kataras/iris/tree/master/_examples) [![chat](https://img.shields.io/gitter/room/iris_go/community.svg?color=cc2b5e&logo=gitter&style=for-the-badge)](https://gitter.im/iris_go/community) [![donate](https://img.shields.io/badge/support-Iris-blue.svg?style=for-the-badge&logo=paypal)](https://iris-go.com/donate) Iris is a fast, simple yet fully featured and very efficient web framework for Go. It provides a beautifully expressive and easy to use foundation for your next website or API. Learn what [others saying about Iris](https://iris-go.com/testimonials/) and **[star](https://github.com/kataras/iris/stargazers)** this open-source project to support its potentials. [![](https://iris-go.com/images/reviews.gif)](https://iris-go.com/testimonials/) [![Benchmarks: Jul 18, 2020 at 10:46am (UTC)](https://iris-go.com/images/benchmarks.svg)](https://github.com/kataras/server-benchmarks) ## 👑 Supporters
## 📖 Learning Iris ```sh # https://github.com/kataras/iris/wiki/Installation $ go get github.com/kataras/iris/v12@master # assume the following code in main.go file $ cat main.go ``` ```go package main import "github.com/kataras/iris/v12" func main() { app := iris.New() booksAPI := app.Party("/books") { booksAPI.Use(iris.Compression) // GET: http://localhost:8080/books booksAPI.Get("/", list) // POST: http://localhost:8080/books booksAPI.Post("/", create) } app.Listen(":8080") } // Book example. type Book struct { Title string `json:"title"` } func list(ctx iris.Context) { books := []Book{ {"Mastering Concurrency in Go"}, {"Go Design Patterns"}, {"Black Hat Go"}, } ctx.JSON(books) // TIP: negotiate the response between server's prioritizes // and client's requirements, instead of ctx.JSON: // ctx.Negotiation().JSON().MsgPack().Protobuf() // ctx.Negotiate(books) } func create(ctx iris.Context) { var b Book err := ctx.ReadJSON(&b) // TIP: use ctx.ReadBody(&b) to bind // any type of incoming data instead. if err != nil { ctx.StopWithProblem(iris.StatusBadRequest, iris.NewProblem(). Title("Book creation failure").DetailErr(err)) // TIP: use ctx.StopWithError(code, err) when only // plain text responses are expected on errors. return } println("Received Book: " + b.Title) ctx.StatusCode(iris.StatusCreated) } ``` **MVC** equivalent: ```go import "github.com/kataras/iris/v12/mvc" ``` ```go m := mvc.New(booksAPI) m.Handle(new(BookController)) ``` ```go type BookController struct { /* dependencies */ } // GET: http://localhost:8080/books func (c *BookController) Get() []Book { return []Book{ {"Mastering Concurrency in Go"}, {"Go Design Patterns"}, {"Black Hat Go"}, } } // POST: http://localhost:8080/books func (c *BookController) Post(b Book) int { println("Received Book: " + b.Title) return iris.StatusCreated } ``` **Run** your Iris web server: ```sh $ go run main.go > Now listening on: http://localhost:8080 > Application started. Press CTRL+C to shut down. ``` **List** Books: ```sh $ curl --header 'Accept-Encoding:gzip' http://localhost:8080/books [ { "title": "Mastering Concurrency in Go" }, { "title": "Go Design Patterns" }, { "title": "Black Hat Go" } ] ``` **Create** a new Book: ```sh $ curl -i -X POST \ --header 'Content-Encoding:gzip' \ --header 'Content-Type:application/json' \ --data "{\"title\":\"Writing An Interpreter In Go\"}" \ http://localhost:8080/books > HTTP/1.1 201 Created ``` That's how an **error** response looks like: ```sh $ curl -X POST --data "{\"title\" \"not valid one\"}" \ http://localhost:8080/books > HTTP/1.1 400 Bad Request { "status": 400, "title": "Book creation failure" "detail": "invalid character '\"' after object key", } ``` [![run in the browser](https://img.shields.io/badge/Run-in%20the%20Browser-348798.svg?style=for-the-badge&logo=repl.it)](https://bit.ly/2YJeSZe) Iris contains extensive and thorough **[wiki](https://github.com/kataras/iris/wiki)** making it easy to get started with the framework. For a more detailed technical documentation you can head over to our [godocs](https://godoc.org/github.com/kataras/iris). And for executable code you can always visit the [./_examples](_examples) repository's subdirectory. ### Do you like to read while traveling? [![follow Iris web framework on twitter](https://img.shields.io/twitter/follow/iris_framework?color=ee7506&logoColor=ee7506&style=for-the-badge&logo=twitter)](https://twitter.com/intent/follow?screen_name=iris_framework) [![follow Iris web framework on facebook](https://img.shields.io/badge/Follow%20%40Iris.framework-453-2D88FF.svg?style=for-the-badge&logo=facebook)](https://www.facebook.com/iris.framework) You can [request](https://www.iris-go.com/#ebookDonateForm) a PDF version and online access of the **E-Book** today and be participated in the development of Iris. ## 🙌 Contributing We'd love to see your contribution to the Iris Web Framework! For more information about contributing to the Iris project please check the [CONTRIBUTING.md](CONTRIBUTING.md) file. [List of all Contributors](https://github.com/kataras/iris/graphs/contributors) ## 🛡 Security Vulnerabilities If you discover a security vulnerability within Iris, please send an e-mail to [iris-go@outlook.com](mailto:iris-go@outlook.com). All security vulnerabilities will be promptly addressed. ## 📝 License This project is licensed under the [BSD 3-clause license](LICENSE), just like the Go project itself. The project name "Iris" was inspired by the Greek mythology.