The fastest HTTP/2 Go Web Framework. New, modern and easy to learn. Fast development with Code you control. Unbeatable cost-performance ratio 🚀
Go to file
Gerasimos (Makis) Maropoulos d98da25ffb add a README note about the known issues for Go inside code editors/IDEs
Former-commit-id: a4be78e746f5675291bab5a1b3e62eaf42cbd98c
2018-08-02 01:58:46 +03:00
_benchmarks fix _benchmarks/iris-mvc-templates 2017-12-31 20:33:33 +02:00
_examples add a README note about the known issues for Go inside code editors/IDEs 2018-08-02 01:58:46 +03:00
.github Sessions are now in full sync with the registered database, on acquire(init), set, get, delete, clear, visit, len, release(destroy) as requested by almost everyone. https://github.com/kataras/iris/issues/969 2018-04-22 13:52:36 +03:00
cache misspell fixes 2018-03-21 08:59:37 +02:00
context Cookies: Ability to set custom cookie encoders to encode the cookie's value before sent by ctx.SetCookie and ctx.SetCookieKV and cookie decoders to decode the cookie's value when retrieving from ctx.GetCookie. That was the second and final part relative to a community's question at: https://github.com/kataras/iris/issues/1018 2018-06-02 16:35:18 +03:00
core update deps and move one vendor to our organisation for making a new branch in order to solve this: https://github.com/kataras/iris/issues/1040, although it's not ours problem... 2018-07-15 16:09:03 +03:00
hero add vscode extension link and badge | Some internal improvements (not completed yet) 2018-01-25 03:16:49 +02:00
httptest Some minor but helpful additions, like CookieOption. Relative: https://github.com/kataras/iris/issues/1018. Simple cookies example added too. Cookie encoding (side by side with the already session's cookie id encoding) and version upgrade will come tomorrow with a new HISTORY.md entry as well, stay tuned! 2018-06-02 07:28:40 +03:00
middleware middleware/logger: new configuration field, defaults to false: Query bool, if true prints the full path, including the URL query as requested at https://github.com/kataras/iris/issues/1017 2018-05-31 01:39:23 +03:00
mvc remove the complicated fallback handlers, that didn't work and not approve the coblexity addition of the https://github.com/kataras/iris/pull/919, RouteExists accepts first argument the Context, add new AllowMethods per party and fix cors by 048e2be034 https://github.com/kataras/iris/issues/922, rel: https://github.com/iris-contrib/middleware/issues/36, https://github.com/iris-contrib/middleware/issues/34, https://github.com/iris-contrib/middleware/issues/32, https://github.com/iris-contrib/middleware/issues/30, https://github.com/kataras/iris/pull/909 2018-03-10 14:22:56 +02:00
sessions update deps and move one vendor to our organisation for making a new branch in order to solve this: https://github.com/kataras/iris/issues/1040, although it's not ours problem... 2018-07-15 16:09:03 +03:00
typescript add a code snippet as a very simplistic overview and update the license dates from 2017 to 2017-2018 2017-12-31 06:45:12 +02:00
view Update vendor for Pug (Jade) Parser and add Iris + Pug examples in the _examples/view folder, relative to https://github.com/kataras/iris/issues/1003 2018-05-26 22:49:48 +03:00
websocket Minified the client.js using UglifyJs 2018-07-30 14:27:28 +05:30
.gitattributes update protobuf vendor for badger session database 2018-06-24 14:24:58 +03:00
.gitignore update protobuf vendor for badger session database 2018-06-24 14:24:58 +03:00
.travis.yml Sessions are now in full sync with the registered database, on acquire(init), set, get, delete, clear, visit, len, release(destroy) as requested by almost everyone. https://github.com/kataras/iris/issues/969 2018-04-22 13:52:36 +03:00
AUTHORS Update to version 8.5.5 | Read HISTORY.md 2017-11-02 05:54:33 +02:00
CODE_OF_CONDUCT.md Update to version 8.5.5 | Read HISTORY.md 2017-11-02 05:54:33 +02:00
configuration_test.go Do not create the global configuration in homedir by-default, as, correctly, requested on chat. Use iris.WithGlobalConfiguration with a pre-defined iris.yml file on your home directory, existing users will not have any issues, new one will have to create the file before 2018-03-27 09:59:29 +03:00
configuration.go Do not create the global configuration in homedir by-default, as, correctly, requested on chat. Use iris.WithGlobalConfiguration with a pre-defined iris.yml file on your home directory, existing users will not have any issues, new one will have to create the file before 2018-03-27 09:59:29 +03:00
CONTRIBUTING.md Sessions are now in full sync with the registered database, on acquire(init), set, get, delete, clear, visit, len, release(destroy) as requested by almost everyone. https://github.com/kataras/iris/issues/969 2018-04-22 13:52:36 +03:00
deprecated.go remove old deprecated code from previous version, no need to keep backward compatibility, it was two months ago v10.0.0 released so we should be ok now 2018-02-12 06:03:15 +02:00
doc.go Update to version 10.6.6. Read https://github.com/kataras/iris/blob/master/HISTORY.md#tu-05-june-2018--v1066 for more 2018-06-05 01:24:35 +03:00
Dockerfile Update to version 8.5.5 | Read HISTORY.md 2017-11-02 05:54:33 +02:00
Dockerfile.build no need to default the Configuration.RemoteAddrHeaders to a list of 'dissalowed' header names, the ctx.RemoteAddr() made unnecessary checks if no X-header was passed, even if they defaulted to false, this will not give a crazy improvement but it's a good practise 2018-01-25 06:31:05 +02:00
FAQ.md add vscode extension link and badge | Some internal improvements (not completed yet) 2018-01-25 03:16:49 +02:00
go19.go Some minor but helpful additions, like CookieOption. Relative: https://github.com/kataras/iris/issues/1018. Simple cookies example added too. Cookie encoding (side by side with the already session's cookie id encoding) and version upgrade will come tomorrow with a new HISTORY.md entry as well, stay tuned! 2018-06-02 07:28:40 +03:00
Gopkg.lock update deps and move one vendor to our organisation for making a new branch in order to solve this: https://github.com/kataras/iris/issues/1040, although it's not ours problem... 2018-07-15 16:09:03 +03:00
Gopkg.toml update deps and move one vendor to our organisation for making a new branch in order to solve this: https://github.com/kataras/iris/issues/1040, although it's not ours problem... 2018-07-15 16:09:03 +03:00
HISTORY_GR.md Update to version 10.6.6. Read https://github.com/kataras/iris/blob/master/HISTORY.md#tu-05-june-2018--v1066 for more 2018-06-05 01:24:35 +03:00
HISTORY_ID.md Update to version 10.6.6. Read https://github.com/kataras/iris/blob/master/HISTORY.md#tu-05-june-2018--v1066 for more 2018-06-05 01:24:35 +03:00
HISTORY_ZH.md Update to version 10.6.6. Read https://github.com/kataras/iris/blob/master/HISTORY.md#tu-05-june-2018--v1066 for more 2018-06-05 01:24:35 +03:00
HISTORY.md Update to version 10.6.6. Read https://github.com/kataras/iris/blob/master/HISTORY.md#tu-05-june-2018--v1066 for more 2018-06-05 01:24:35 +03:00
iris.go Cookies: Ability to set custom cookie encoders to encode the cookie's value before sent by ctx.SetCookie and ctx.SetCookieKV and cookie decoders to decode the cookie's value when retrieving from ctx.GetCookie. That was the second and final part relative to a community's question at: https://github.com/kataras/iris/issues/1018 2018-06-02 16:35:18 +03:00
LICENSE add a code snippet as a very simplistic overview and update the license dates from 2017 to 2017-2018 2017-12-31 06:45:12 +02:00
README_GR.md Update to version 10.6.6. Read https://github.com/kataras/iris/blob/master/HISTORY.md#tu-05-june-2018--v1066 for more 2018-06-05 01:24:35 +03:00
README_ID.md Update to version 10.6.6. Read https://github.com/kataras/iris/blob/master/HISTORY.md#tu-05-june-2018--v1066 for more 2018-06-05 01:24:35 +03:00
README_JPN.md Update to version 10.6.6. Read https://github.com/kataras/iris/blob/master/HISTORY.md#tu-05-june-2018--v1066 for more 2018-06-05 01:24:35 +03:00
README_PT_BR.md Update to version 10.6.6. Read https://github.com/kataras/iris/blob/master/HISTORY.md#tu-05-june-2018--v1066 for more 2018-06-05 01:24:35 +03:00
README_RU.md Update to version 10.6.6. Read https://github.com/kataras/iris/blob/master/HISTORY.md#tu-05-june-2018--v1066 for more 2018-06-05 01:24:35 +03:00
README_ZH.md Update to version 10.6.6. Read https://github.com/kataras/iris/blob/master/HISTORY.md#tu-05-june-2018--v1066 for more 2018-06-05 01:24:35 +03:00
README.md add a README note about the known issues for Go inside code editors/IDEs 2018-08-02 01:58:46 +03:00
VERSION Update to version 10.6.6. Read https://github.com/kataras/iris/blob/master/HISTORY.md#tu-05-june-2018--v1066 for more 2018-06-05 01:24:35 +03:00

Iris Web Framework

build status report card vscode-iris chat view examples release

Iris is a fast, simple yet fully featured and very efficient web framework for Go.

Iris provides a beautifully expressive and easy to use foundation for your next website or API.

Finally, a real expressjs equivalent for the Go Programming Language.

Learn what others say about Iris and star this github repository to stay up to date.

Installation

The only requirement is the Go Programming Language

$ go get -u github.com/kataras/iris

Iris takes advantage of the vendor directory feature. You get truly reproducible builds, as this method guards against upstream renames and deletes.

Iris vs .NET Core(C#) vs Node.js (Express)

Updated at: Tuesday, 21 November 2017

Benchmarks from third-party source over the rest web frameworks

Comparison with other frameworks

Known issues for code editors and IDEs at general

VS Code

For some reason the latest vscode-go language extension does not provide enough intelligence for the iris.Context type alias (input parameters documentation and definition navigation). Probably you have already experienced this issue with other Go libraries too, it is not an iris-specific issue, it is a general issue for all Golang type aliases.

Therefore if you use VS Code and you need these editor's features, import the original path; add an extra import statement of the original path of the Context, that will do it:

import (
    "github.com/kataras/iris"
    "github.com/kataras/iris/context" // <- HERE
)

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, so far, iris is the fastest web framework ever created in terms of performance.

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.

Quick start

$ cat example.go
package main

import "github.com/kataras/iris"

func main() {
    app := iris.Default()
    app.Get("/ping", func(ctx iris.Context) {
        ctx.JSON(iris.Map{
            "message": "pong",
        })
    })

    // Listen and serve on http://localhost:8080.
    app.Run(iris.Addr(":8080"))
}
$ go run example.go
Now listening on: http://localhost:8080
Application Started. Press CTRL+C to shut down.
_

Using Get, Post, Put, Patch, Delete and Options

func main() {
    // Creates an application with default middleware:
    // logger and recovery (crash-free) middleware.
    app := iris.Default()

    app.Get("/someGet", getting)
    app.Post("/somePost", posting)
    app.Put("/somePut", putting)
    app.Delete("/someDelete", deleting)
    app.Patch("/somePatch", patching)
    app.Head("/someHead", head)
    app.Options("/someOptions", options)

    app.Run(iris.Addr(":8080"))
}

Parameters in path

func main() {
    app := iris.Default()

    // This handler will match /user/kataras but will not match neither /user/ or /user.
    app.Get("/user/{name}", func(ctx iris.Context) {
        name := ctx.Params().Get("name")
        ctx.Writef("Hello %s", name)
    })

    // This handles the /user/kataras/42
    // and fires 400 bad request if /user/kataras/string.
    // The "else 400" is optionally:
    // by-default it will fire 404 not found if alphanumeric instead
    // of number passed on the "age" parameter.
    app.Get("/user/{name:string}/{age:int else 400}", func(ctx iris.Context) {
        name := ctx.Params().Get("name")
        age, _ := ctx.Params().GetInt("age")
        ctx.Writef("%s is %d years old", name, age)
    })

    // However, this one will match /action/{user}/star and also /action/{user}/stars
    // or even /action/{user}/likes/page/2.
    // It should match anything after the /action/{user}/
    // except the /action/{user}/static which is handled by the below route.
    app.Get("/action/{user:string}/{action:path}", func(ctx iris.Context) {
        user := ctx.Params().Get("user")
        action := ctx.Params().Get("action")
        ctx.Writef("user: %s | action: %s", user, action)
    })

    // Unlike other frameworks and routers,
    // Iris is smart enough to understand that this is not the previous,
    // wildcard of type path route, it should only match the /action/{user}/static.
    app.Get("/action/{user:string}/static", func(ctx iris.Context) {
        user := ctx.Params().Get("user")
        ctx.Writef("static path for user: %s", user)
    })


    // http://localhost:8080/user/kataras
    // http://localhost:8080/user/kataras/25
    // http://localhost:8080/action/kataras/upgrade
    // http://localhost:8080/action/kataras/static
    app.Run(iris.Addr(":8080"))
}

If parameter type is missing then defaults to string, therefore {name:string} and {name} do the same exactly thing.

Learn more about path parameter's types by navigating here.

Cookies

$ cat _examples/cookies/basic/main.go
package main

import "github.com/kataras/iris"

func newApp() *iris.Application {
    app := iris.New()

    // Set A Cookie.
    app.Get("/cookies/{name}/{value}", func(ctx iris.Context) {
        name := ctx.Params().Get("name")
        value := ctx.Params().Get("value")

        ctx.SetCookieKV(name, value)

        ctx.Writef("cookie added: %s = %s", name, value)
    })

    // Retrieve A Cookie.
    app.Get("/cookies/{name}", func(ctx iris.Context) {
        name := ctx.Params().Get("name")

        value := ctx.GetCookie(name)

        ctx.WriteString(value)
    })

    // Delete A Cookie.
    app.Delete("/cookies/{name}", func(ctx iris.Context) {
        name := ctx.Params().Get("name")

        ctx.RemoveCookie(name)

        ctx.Writef("cookie %s removed", name)
    })

    return app
}

func main() {
    app := newApp()

    // GET:    http://localhost:8080/cookies/my_name/my_value
    // GET:    http://localhost:8080/cookies/my_name
    // DELETE: http://localhost:8080/cookies/my_name
    app.Run(iris.Addr(":8080"))
}
  • Alternatively, use a regular http.Cookie: ctx.SetCookie(&http.Cookie{...})
  • If you want to set custom the path: ctx.SetCookieKV(name, value, iris.CookiePath("/custom/path/cookie/will/be/stored")).
  • If you want to be available only to the current request path: ctx.SetCookieKV(name, value, iris.CookieCleanPath /* or iris.CookiePath("") */)
    • iris.CookieExpires(time.Duration)
    • iris.CookieHTTPOnly(false)
  • ctx.Request().Cookie(name) is also available, it's the net/http approach
  • Learn more about path parameter's types by clicking here.

Testing

package main

import (
    "fmt"
    "testing"

    "github.com/kataras/iris/httptest"
)

// go test -v -run=TestCookiesBasic$
func TestCookiesBasic(t *testing.T) {
    app := newApp()
    e := httptest.New(t, app, httptest.URL("http://example.com"))

    cookieName, cookieValue := "my_cookie_name", "my_cookie_value"

    // Test Set A Cookie.
    t1 := e.GET(fmt.Sprintf("/cookies/%s/%s", cookieName, cookieValue)).Expect().Status(httptest.StatusOK)
    t1.Cookie(cookieName).Value().Equal(cookieValue) // validate cookie's existence, it should be there now.
    t1.Body().Contains(cookieValue)

    path := fmt.Sprintf("/cookies/%s", cookieName)

    // Test Retrieve A Cookie.
    t2 := e.GET(path).Expect().Status(httptest.StatusOK)
    t2.Body().Equal(cookieValue)

    // Test Remove A Cookie.
    t3 := e.DELETE(path).Expect().Status(httptest.StatusOK)
    t3.Body().Contains(cookieName)

    t4 := e.GET(path).Expect().Status(httptest.StatusOK)
    t4.Cookies().Empty()
    t4.Body().Empty()
}

Learn

First of all, the most correct way to begin with a web framework is to learn the basics of the programming language and the standard http capabilities, if your web application is a very simple personal project without performance and maintainability requirements you may want to proceed just with the standard packages. After that follow the guidelines:

  • Navigate through 100+1 examples and some iris starter kits we crafted for you
  • Read the godocs for any details
  • Prepare a cup of coffee or tea, whatever pleases you the most, and read some articles we found for you

Iris starter kits

  1. A basic web app built in Iris for Go
  2. A mini social-network created with the awesome Iris💖💖
  3. Iris isomorphic react/hot reloadable/redux/css-modules starter kit
  4. Demo project with react using typescript and Iris
  5. Self-hosted Localization Management Platform built with Iris and Angular
  6. Iris + Docker and Kubernetes
  7. Quickstart for Iris with Nanobox
  8. A Hasura starter project with a ready to deploy Golang hello-world web app with IRIS

Did you build something similar? Let us know!

Middleware

Iris has a great collection of handlers[1][2] that you can use side by side with your web apps. However you are not limited to them - you are free to use any third-party middleware that is compatible with the net/http package, _examples/convert-handlers will show you the way.

Iris, unlike others, is 100% compatible with the standards and that's why the majority of the big companies that adapt Go to their workflow, like a very famous US Television Network, trust Iris; it's up-to-date and it will be always aligned with the std net/http package which is modernized by the Go Authors on each new release of the Go Programming Language.

Articles

Video Courses

Name Producer
Daily Coding - Web Framework Golang: Iris Framework WarnabiruTV
Playlist: Tutorial Golang MVC Iris Framework Musobar Media
Go/Golang 27 - Iris framework : Routage de base stephgdesign
Go/Golang 28 - Iris framework : Templating stephgdesign
Go/Golang 29 - Iris framework : Paramètres stephgdesign
Go/Golang 30 - Iris framework : Les middelwares stephgdesign
Go/Golang 31 - Iris framework : Les sessions stephgdesign

Support

  • HISTORY file is your best friend, it contains information about the latest features and changes
  • Did you happen to find a bug? Post it at github issues
  • Do you have any questions or need to speak with someone experienced to solve a problem at real-time? Join us to the community chat
  • Complete our form-based user experience report by clicking here
  • Do you like the framework? Tweet something about it! The People have spoken:



For more information about contributing to the Iris project please check the CONTRIBUTING.md file.

List of all Contributors

Get hired

There are many companies and start-ups looking for Go web developers with Iris experience as requirement, we are searching for you every day and we post those information via our facebook page, like the page to get notified, we have already posted some of them.

Backers

Thank you to all our backers! 🙏 Become a backer

License

Iris is licensed under the 3-Clause BSD License. Iris is 100% free and open-source software.

For any questions regarding the license please send e-mail.