The fastest HTTP/2 Go Web Framework. AWS Lambda, gRPC, MVC, Unique Router, Websockets, Sessions, Test suite, Dependency Injection and more. A true successor of expressjs and laravel | 谢谢 https://github.com/kataras/iris/issues/1329 |

Overview

Black Lives Matter

News

This is the under-development branch. Stay tuned for the upcoming release v12.2.0. Looking for a stable release? Head over to the v12.1.8 branch instead.

Try the official Iris Command Line Interface today!

Due to the large workload, there may be delays in answering your questions.

Iris Web Framework

build status view examples chat 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.

Simple Handler
package main

import "github.com/kataras/iris/v12"

type (
  request struct {
    Firstname string `json:"firstname"`
    Lastname  string `json:"lastname"`
  }

  response struct {
    ID      uint64 `json:"id"`
    Message string `json:"message"`
  }
)

func main() {
  app := iris.New()
  app.Handle("PUT", "/users/{id:uint64}", updateUser)
  app.Listen(":8080")
}

func updateUser(ctx iris.Context) {
  id, _ := ctx.Params().GetUint64("id")

  var req request
  if err := ctx.ReadJSON(&req); err != nil {
    ctx.StopWithError(iris.StatusBadRequest, err)
    return
  }

  resp := response{
    ID:      id,
    Message: req.Firstname + " updated successfully",
  }
  ctx.JSON(resp)
}

Read the routing examples for more!

Handler with custom input and output arguments

https://github.com/kataras/iris/blob/master/_examples/dependency-injection/basic/main.go

Interesting? Read the examples.

MVC
package main

import (
  "github.com/kataras/iris/v12"
  "github.com/kataras/iris/v12/mvc"
)

type (
  request struct {
    Firstname string `json:"firstname"`
    Lastname  string `json:"lastname"`
  }

  response struct {
    ID      uint64 `json:"id"`
    Message string `json:"message"`
  }
)

func main() {
  app := iris.New()
  mvc.Configure(app.Party("/users"), configureMVC)
  app.Listen(":8080")
}

func configureMVC(app *mvc.Application) {
  app.Handle(new(userController))
}

type userController struct {
  // [...dependencies]
}

func (c *userController) PutBy(id uint64, req request) response {
  return response{
    ID:      id,
    Message: req.Firstname + " updated successfully",
  }
}

Want to see more? Navigate through mvc examples!

Learn what others saying about Iris and star this open-source project to support its potentials.

Benchmarks: Jul 18, 2020 at 10:46am (UTC)

👑 Supporters

With your help, we can improve Open Source web development for everyone!

Donations from China are now accepted!

George Fourikis Александр Лебединский Li Yang Qianyu Zhou anilpdv CAO HOAI BAO Oscar Hernandez Gerard Lancea neulhan xushiquan Matt Ľuboš Pinteš Leighton McKeen Weliam simranjit singh Kenneth Jordan Morlé Koudeka Rui Carlos Augusto Horst Ender Pavithran MULYAWAN SENTOSA KIT UNITED Ricardo Hernandez Lopez ChinChuanKuo Nikhar Saxena Servio Zambrano Nate Anderson Claude Muller Marco Moeser Sanketh P B Vu Hoang Lam Dimitar Trifonov Midhubalan Balasubramanian AANAND NATARAJAN Edsongley Almeida ganben Tejus Pratap cui hexiang tinawang Juan David Parra Pimiento Andy Chong Ying Zhi Kevin Zhou Jasper Simranjit Singh Christopher Lamm 叶峻峣 TSAI LI TING zhutao George Alexiou Jobert Azares Tam Nguyen 
Venkatt Guhesan Anibal C C Budaye ARAN ROKA Valentine Chakravarthy Raghunandan Massimiliano Bertinetti Hieu Trinh J.T. Feng Gabor Lekeny LiHaotian Muyang Li Hao Tu Cetin Basoz Hazmi Amalul Rémy Deme Vincent Li Max Trense Matej Lach Joseph De Paola Damon Blais 陆 轶丰 Weihang Ding Li Fang TechMaster lenses.io Celso Souza Altafino Thomas Fritz Conrad Steenberg Damon Zhao George Opritescu Juanses Ankur Srivastava Lex Tang li3p

📖 Learning Iris

Create a new project

$ mkdir myapp
$ cd myapp
$ go mod init myapp
$ go get github.com/kataras/iris/[email protected] # or @v12.2.0-alpha2
Install on existing project
$ cd myapp
$ go get github.com/kataras/iris/[email protected]
Install with a go.mod file
module myapp

go 1.16

require github.com/kataras/iris/v12 master

Run

$ go mod download
$ go run main.go
# OR just:
# go run -mod=mod main.go

Iris contains extensive and thorough documentation making it easy to get started with the framework.

For a more detailed technical documentation you can head over to our godocs. And for executable code you can always visit the ./_examples repository's subdirectory.

Do you like to read while traveling?

Book cover

follow author on twitter

follow Iris web framework on twitter

follow Iris web framework on facebook

You can request a PDF and online access of the Iris E-Book (New Edition, future v12.2.0+) 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 file.

List of all Contributors

🛡 Security Vulnerabilities

If you discover a security vulnerability within Iris, please send an e-mail to [email protected]. All security vulnerabilities will be promptly addressed.

📝 License

This project is licensed under the BSD 3-clause license, just like the Go project itself.

The project name "Iris" was inspired by the Greek mythology.

Issues
  • [QUESTION]can logger write to multiple files asynchronously and rotate based on size or time?

    [QUESTION]can logger write to multiple files asynchronously and rotate based on size or time?

    I need to write different level to different file for example: INFO & WARN level write toinfo.log ERRO level write to error.log In addition, I need to save the access log including request params and response data to access.log

    If the log files become more and more large, I expect that logger can automatically rotate the log files based on size or time

    Does logger support the requirements above and write file asynchronously?

    question type:idea status:implemented 
    opened by tuhao1020 57
  • [DOCUMENTATION] No Content-Encoding: gzip header on gzip-ed bindata

    [DOCUMENTATION] No Content-Encoding: gzip header on gzip-ed bindata

    Describe the bug I use kataras/bindata to embeding some files, but iris reponse without Content-Encoding: gzip header

    To Reproduce

    go get -u github.com/kataras/bindata/cmd/bindata
    bindata ./public/...
    go build
    
    	app.HandleDir("/static", "./public", iris.DirOptions{
    		Asset:      GzipAsset,
    		AssetInfo:  GzipAssetInfo,
    		AssetNames: GzipAssetNames,
    	})
    

    The public dir has only one file index.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>NMac Mirror</title>
    </head>
    <body>
    Hello!
    </body>
    </html>
    

    Screenshots image

    Desktop MacOS 10.14.6

    status:resolved type:documentation 
    opened by xiaozhuai 28
  • Ability to customize Logrus

    Ability to customize Logrus

    Logrus is a popular logging package. Some already use this in their projects, and set it up with Console in dev and JSON writers in production. It would be nice to add the ability to customize Logrus inside of Iris. I propose and could easily add the ability to set the Logrus object to use. Even better, would be nice to have it's own context.

    type:idea status:implemented 
    opened by mattrmiller 24
  • websocket rebuild 2019

    websocket rebuild 2019

    i have got the mel formed json from the websocket output. Currently found out that is caused by some race detection from the data transmission. it is the same issue caused by unsafe access in ByteBuffer.

    type:bug status:resolved 
    opened by jjhesk 24
  • [BUG] CORS doesn't support Subdomains

    [BUG] CORS doesn't support Subdomains

    Summary

    I attempted to host my assets directory as a Subdomain, which Chrome complained requires CORS. So, I followed the example code within the repository (which, btw, doesn't work on a Party, but only on the entire server, so is incompatible with subdomains), and found that it doesn't work at all.

    Screenshot

    image

    Versions, etc.

    |Thing|Version| |-|-| |Golang|1.14.6 linux/amd64| |Iris|master d0d7679| |Kernel|5.7.14-200.fc32.x86_64| |OS|Fedora 32 Workstation|

    Sample Code

    	c := cors.New(cors.Options{
    		AllowedOrigins: []string{
    			*domain,
    			fmt.Sprintf("www.%s", *domain),
    			fmt.Sprintf("your.%s", *domain),
    		},
    		AllowCredentials: true,
    	})
    	app.WrapRouter(c.ServeHTTP)
    
    	// define subdomain "your."
    	your := app.Subdomain("your")
    	your.Use(requestid.New())
    
    	// host the ./public directory as subdomain `static.`
    	assets := app.Subdomain("static")
    	assets.HandleDir("/", iris.Dir("./public"), iris.DirOptions{
    		Compress:  true,
    		DirList:   iris.DirList,
    		IndexName: "/index.html",
    		ShowList:  false,
    		Cache: iris.DirCacheOptions{
    			Enable:          true,
    			CompressIgnore:  iris.MatchImagesAssets,
    			CompressMinSize: 1,
    			Encodings:       []string{"gzip", "br", "deflate", "snappy"},
    		},
    	})
    
    	// redirect root domain to `your.`
    	app.SubdomainRedirect(app, your)
    
    	// Redirect www subdomains to `your.`
    	app.SubdomainRedirect(app.Subdomain("www"), your)
    
    type:bug 
    opened by AlbinoGeek 21
  • AutoTLS with non-80 HTTP Port?

    AutoTLS with non-80 HTTP Port?

    Hello there!

    This is a purely documentation / example question:

    • How can I start an AutoTLS server, where the HTTP port is 8080 and not 80?

    Why?

    Because there is NAT in front of iris that routes internal:8080 to external:80

    Current Code

    if err := app.Run(iris.AutoTLS(":443", "my.domain.here", "[email protected]")); err != nil {
      log.Error("failed to set-up HTTP server", "error", err)
    }
    

    Looking through the code some I the two ways to create a Runner that conflict here: https://github.com/kataras/iris/blob/da029d6f37228c7c0fed685187a2bd4ef35b5b3e/iris.go#L658-L667 https://github.com/kataras/iris/blob/da029d6f37228c7c0fed685187a2bd4ef35b5b3e/iris.go#L584-L590

    They are simply too abstracted for me to know what I'd be changing without a thorough deep-dive into iris code.

    status:resolved 
    opened by AlbinoGeek 19
  • Poor performance of session.UpdateExpiration on 200 thousands+ keys with new radix lib

    Poor performance of session.UpdateExpiration on 200 thousands+ keys with new radix lib

    Hello Makis!

    I have more 200 thousands key in redis on prod server and found that after upgrading iris on v11 from redigo to radix lib that I have problems with perfomance when calling session.UpdateExpiration method (it`s executing minimum 10 seconds on a powerful prod server and more than 30 seconds on usual local).

    While debugging I found place where freezes, it`s here:

    func (r *Service) UpdateTTLMany(prefix string, newSecondsLifeTime int64) error {
    	keys, err := r.getKeys(prefix)
    	if err != nil {
    		return err
    	}
    ...
    }
    

    and inside getKeys here:

    scanner := radix.NewScanner(r.pool, radix.ScanOpts{
    		Command: "SCAN",
    		Pattern: r.Config.Prefix + prefix + r.Config.Delim + "*", // get all of this session except its root sid.
    		//	Count: 9999999999,
    	})
    
    	var key string
    	for scanner.Next(&key) {
    		keys = append(keys, key)
    	}
    

    Just has watched old v10 iris and old method getKeysConn did not cause such delay ...

    func (r *Service) getKeysConn(c redis.Conn, prefix string) ([]string, error) {
    	if err := c.Send("SCAN", 0, "MATCH", r.Config.Prefix+prefix+"*", "COUNT", 9999999999); err != nil {
    		return nil, err
    	}
    
    	if err := c.Flush(); err != nil {
    		return nil, err
    	}
    
    	reply, err := c.Receive()
    	if err != nil || reply == nil {
    		return nil, err
    	}
    

    Maybe reason in difference between old and new scan commands? Could you help?

    status:resolved prio:high 
    opened by r3eg 18
  • [FEATURE REQUEST] MVC serving gRPC-compatible controller

    [FEATURE REQUEST] MVC serving gRPC-compatible controller

    Is your feature request related to a problem? Please describe.

    currently iris mvc would accept a controller func like

    
    func (s *acctService) PostLogin(ctx iris.Context, input *LoginParam) (*LoginResult, error) {}
    
    

    It just like a grpc service func, but when i change iris.Context to context.Context, it cause panic. Instead writing a wrapper func, could iris.MVC support context.Context as input parameter? If ture, then all the grpc services could serve by iris.MVC without adding a line.

    Describe the solution you'd like could accept like this

    
    func (s *acctService) PostLogin(ctx context.Context, input *LoginParam) (*LoginResult, error) {}
    
    

    Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

    Additional context Add any other context or screenshots about the feature request here.

    type:idea type:feature status:implemented 
    opened by syklevin 18
  • How can we call a controller method as scheduled(e.g. using crontab)?

    How can we call a controller method as scheduled(e.g. using crontab)?

    I want to call an API as scheduled. Is there any solution to exec some API once timeout?

    question 
    opened by zheeeng 17
  • [BUG/Feature] MVC Dependency authentication example

    [BUG/Feature] MVC Dependency authentication example

    Describe the bug on the master branch "https://github.com/kataras/iris/blob/master/_examples/mvc/authenticated-controller/main.go" an authentication is used to show how it is done when you search for an authenticated user. But how can I find an unauthenticated user who can call the same route but from a different controller?

    To Reproduce Steps to reproduce the behavior:

    1. [...]

    Expected behavior Let's take two controllers that are both registered for the same route, but one of them has no authentication feature. Now when I call the route, I want the call without authentication to return a different value than if I were authenticated.

    Screenshots If applicable, add screenshots to help explain your problem.

    Desktop (please complete the following information):

    • OS: [e.g. ubuntu, windows]

    Additional context I don't think it's a bug, but a feature request, although I think others do as well, that the same route should call a different controller under different circumstances.

    type:feature status:implemented 
    opened by Dexus 17
  • iris set   http request timeout

    iris set http request timeout

    Describe the issue you are facing or ask for help

    HTTP set Read 60s

    HTTP set Write 120s

    srv := &http.Server{
    		Addr:         cf.Domain,
    		ReadTimeout:  60 * time.Second,
    		WriteTimeout: 120 * time.Second,
    	}
    	err := app.Run(iris.Server(srv))
    	if err != nil {
    		service.LogError.Fatalf("IRIS close %s", err)
    	}
    
    

    iris run 8803

    image

    http request

    image

    http request time

    image

    http timeout still 10s

    opened by WyntersN 5
  • [BUG] `Strict: false` in gRPC Configs causes a Panic

    [BUG] `Strict: false` in gRPC Configs causes a Panic

    Describe the bug I am setting up a gRPC server using Iris and trying to disable the need for using authentication/TLS - (i.e. Allow my server to accept http:// requests in addition to https://).

    In order for the gRPC server to accept http connections the mvc.GRPC configuration needs to have the Strict option set to false. The Strict options description is - "When Strict option is true then this controller will only serve gRPC-based clients and fires 404 on common HTTP clients."

    When I use the following configuration...

    mvc.GRPC{
    	Server:      grpcServer,             
    	ServiceName: string(grpcServiceName),
    	Strict:      false,
    }
    

    ...I get the following panic / error on server startup....

    panic: reflect: call of reflect.Value.NumField on ptr Value
    
    goroutine 1 [running]:
    reflect.flag.mustBe(...)
    	/usr/local/go/src/reflect/value.go:221
    reflect.Value.NumField(0x118ff00, 0xc0005c0330, 0x196, 0x140f590)
    	/usr/local/go/src/reflect/value.go:1369 +0xc5
    github.com/kataras/iris/v12/hero.lookupFields(0x118ff00, 0xc0005c0330, 0x196, 0x1, 0xc0005be808, 0x1, 0x1, 0x1, 0x30, 0xc0005be800, ...)
    	/processors/pkg/mod/github.com/kataras/iris/[email protected]/hero/reflect.go:124 +0xa5
    github.com/kataras/iris/v12/hero.lookupFields(0x119aa00, 0xc0005c0300, 0x199, 0x1000001, 0x0, 0x0, 0x0, 0x1, 0x2f, 0x0, ...)
    	/processors/pkg/mod/github.com/kataras/iris/[email protected]/hero/reflect.go:133 +0x616
    github.com/kataras/iris/v12/hero.lookupNonZeroFieldValues(0x119aa00, 0xc0005c0300, 0x199, 0x119aa00, 0xc0005c0300, 0x199)
    	/processors/pkg/mod/github.com/kataras/iris/[email protected]/hero/reflect.go:165 +0x75
    github.com/kataras/iris/v12/hero.getBindingsForStruct(0x1194da0, 0xc0005c0300, 0x16, 0xc000416600, 0xd, 0x18, 0x0, 0x0, 0x1228f78, 0x0, ...)
    	/processors/pkg/mod/github.com/kataras/iris/[email protected]/hero/binding.go:289 +0x105
    github.com/kataras/iris/v12/hero.makeStruct(0x11a2340, 0xc00000e228, 0xc0009923f0, 0x0, 0x10)
    	/processors/pkg/mod/github.com/kataras/iris/[email protected]/hero/struct.go:54 +0x17e
    github.com/kataras/iris/v12/hero.(*Container).Struct(...)
    	/processors/pkg/mod/github.com/kataras/iris/[email protected]/hero/container.go:352
    github.com/kataras/iris/v12/mvc.(*ControllerActivator).attachInjector(0xc0009924d0)
    	/processors/pkg/mod/github.com/kataras/iris/[email protected]/mvc/controller.go:285 +0x1bd
    github.com/kataras/iris/v12/mvc.(*ControllerActivator).handlerOf(0xc0009924d0, 0xc000444360, 0x29, 0xf7ba77, 0x9, 0xc000444360)
    	/processors/pkg/mod/github.com/kataras/iris/[email protected]/mvc/controller.go:445 +0x45
    github.com/kataras/iris/v12/mvc.(*ControllerActivator).handleMany(0xc0009924d0, 0x11a8793, 0x4, 0xc000444360, 0x29, 0xf7ba77, 0x9, 0xc000548400, 0xc0002b28e8, 0x1, ...)
    	/processors/pkg/mod/github.com/kataras/iris/[email protected]/mvc/controller.go:403 +0xfb
    github.com/kataras/iris/v12/mvc.(*ControllerActivator).Handle(...)
    	/processors/pkg/mod/github.com/kataras/iris/[email protected]/mvc/controller.go:347
    github.com/kataras/iris/v12/mvc.GRPC.Apply(0x13e9940, 0xc000406700, 0xc000418bb0, 0x1f, 0x0, 0xc0009924d0)
    	/processors/pkg/mod/github.com/kataras/iris/[email protected]/mvc/grpc.go:59 +0x34e
    github.com/kataras/iris/v12/mvc.(*Application).handle(0xc000992460, 0x1194da0, 0xc0005c0300, 0xc000575ba0, 0x1, 0x1, 0xc00098b650)
    	/processors/pkg/mod/github.com/kataras/iris/[email protected]/mvc/mvc.go:306 +0x205
    github.com/kataras/iris/v12/mvc.(*Application).Handle(0xc000992460, 0x1194da0, 0xc0005c0300, 0xc000575ba0, 0x1, 0x1, 0x1)
    	/processors/pkg/mod/github.com/kataras/iris/[email protected]/mvc/mvc.go:246 +0x65
    main.configureVoice(0xc0005c0300, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    	/myApplication/server.go:42 +0x3d5
    main.main()
    	/myApplication/server.go:73 +0x245
    make: *** [local] Error 2
    

    ...And the stack trace from my own code at /myApplication/server.go:42 is ...

    pb.RegisterMyServer(grpcServer, myServer)
    mvc.New(myApplication).Handle(myServer, mvc.GRPC{
    	Server:      grpcServer,              // Required
    	ServiceName: string(grpcServiceName), // Required
    	Strict:      false,
    })
    

    In the above code snippet myServer is a pointer to a struct.

    To Reproduce Steps to reproduce the behavior:

    Take one of the generic Iris web app / grpc server examples and attempt to set the Strict option in the grpc config to false. Code snippets are provided in the description above for more detail on how this issue was reached.

    Expected behavior A clear and concise description of what you expected to happen.

    Desktop (please complete the following information):

    • (Built On) OS: mac OS Catalina 10.15.7
    • (Run On) OS: Docker Image nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04- https://hub.docker.com/r/nvidia/cuda

    iris.Version

    • v12.2.0-alpha2 - latest release as of making this issue

    Please make sure the bug is reproducible over the master branch: [done]

    $ cd PROJECT
    $ go get -u github.com/kataras/iris/[email protected]
    $ go run .
    

    This bug is reproducible on master

    Screen Shots N/A

    Additional context For reference, not that I would have expected the following hack/workaround to actually resolve the issue, but attempting to dereference the server before passing it to .Handle(...) results in the following error.

    Code:

    mvc.New(myApplication).Handle(*myServer, mvc.GRPC{
    	Server:      grpcServer,              // Required
    	ServiceName: string(grpcServiceName), // Required
    	Strict:      false,
    })
    

    Error: panic: binder: struct: should be a pointer to a struct value

    type:bug 
    opened by ajohnson-veri 3
  • [BUG]Django Template error: Too many file is open

    [BUG]Django Template error: Too many file is open

    Describe the bug
    When I use the html template django and set it reload to true
    Then I flush my web page, many times
    It will response http code 500, and tell me Too many file is open

    To Reproduce
    Steps to reproduce the behavior:

    1. download my project from https://github.com/KpnmServer/kpnm_web , the commit hash is507b6b49427c2be46743902cf5bc041bf06f5f2d
    2. complete it
    3. change the config file at config/config.json, set debug to true
    4. run server
    5. flush the web page, many times
    6. the page will response 500 and tell you Too many file is open

    Expected behavior
    The web will running safe

    Desktop (please complete the following information):

    • OS: Mac

    iris.Version

    • v12.2.0-alpha
    type:bug 
    opened by zyxgad 7
  • Trying to get in touch regarding a security issue

    Trying to get in touch regarding a security issue

    Hey there!

    I'd like to report a security issue but cannot find contact instructions on your repository.

    If not a hassle, might you kindly add a SECURITY.md file with an email, or another contact method? GitHub recommends this best practice to ensure security issues are responsibly disclosed, and it would serve as a simple instruction for security researchers in the future.

    Thank you for your consideration, and I look forward to hearing from you!

    (cc @huntr-helper)

    type:idea status:implemented 
    opened by JamieSlome 1
  • Using redis to store session loss

    Using redis to store session loss

    My login session uses redis DB9 and the expiration time is set to 2 hours. When my application restarts or the page is refreshed in a random period, my login page is redirected because of session loss. In redis DB9, the data is empty, but the data in db1-db8 exists.

    iris.Version

    • e.g. v12.2.0-alpha

    ` sessManager := sessions.New(sessions.Config{ Cookie: "ph_qa", Expires: 2 * time.Hour, AllowReclaim: true, }) sessManager.UseDatabase(db)

    common := mvc.New(app.Party("/"))
    common.Router.Use(middleware.SingleUserAuth(sessManager, rc))
    common.Register(
    	sessManager.Start,
    	services.CommonService{
    		CategoryClient:     CourseCategoryClient,
    		SpocCategoryClient: SpocCategoryClient,
    	},
    )
    common.Handle(new(controllers.CommonController))`
    
    type:bug 
    opened by echobool 0
  • [BUG] proxy chunked enconding upstream erase body when record is active

    [BUG] proxy chunked enconding upstream erase body when record is active

    Describe the bug I setup a chunked encoding response http server at localhost:9394, and try use host.ProxyHandle to proxy it when ctx.Record() is call in middleware, that lead to body be erased.

    To Reproduce Steps to reproduce the behavior:

    package main
    import (
    	"github.com/kataras/iris/v12"
    	"github.com/kataras/iris/v12/context"
    	"github.com/kataras/iris/v12/core/host"
    	"net/http"
    	"net/http/httputil"
    	"net/url"
    )
    
    func recorder(ctx *context.Context) {
    	if _, ok := ctx.IsRecording(); !ok {
    		ctx.Record()
    	}
    
    	ctx.Next()
    }
    
    func main() {
    	http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
    		chunkedWriter := httputil.NewChunkedWriter(writer)
    		writer.Header().Set("Transfer-Encoding", "chunked")
    		chunkedWriter.Write([]byte("hello"))
    		chunkedWriter.Close()
    	})
    
    	go http.ListenAndServe(":9394", nil)
    
    	app := iris.New()
    	app.Use(recorder)
    	u, _ := url.Parse("http://localhost:9394")
    	app.Get("/", iris.FromStd(host.ProxyHandler(u, nil)))
    
    	app.Run(iris.Addr(":9395"))
    }
    
    

    Expected behavior body response to client as normal

    iris.Version

    • v12.1.8
    • go 1.16.4

    Please make sure the bug is reproducible over the master branch:

    $ cd PROJECT
    $ go get -u github.com/kataras/iris/[email protected]
    $ go run .
    

    Additional context a quick workaround is supply ModifyResponse to httputil.ReverseProxy, modify response.ContentLength to 0 when it's -1. (http.ReverseProxy will not call ResponseWriter.Flush in this situation)

    type:bug 
    opened by zxfishhack 0
  • [FEATURE REQUEST] Slack Webhooks for Logging

    [FEATURE REQUEST] Slack Webhooks for Logging

    Is your feature request related to a problem? Please describe. I would like to send all the error as well as request logs to a channel in my slack workspace.

    Describe the solution you'd like Iris is using golog for logging as of now, we can add custom hooks to the package like logrus has to send the logs to the slack channel whenever a log is created.

    Describe alternatives you've considered I have tried configuring logrus with a hook for slack. Then I used app.Logger().Install() to use that logrus instance but had no luck.

    type:idea 
    opened by mintunitish 2
  • [HELP] use app.HandleDir to create static web server

    [HELP] use app.HandleDir to create static web server

    When I use app.HandleDir("/static", iris.Dir("./static")) to create a static server.

    Access " http://xxx/static/doc/index.html " will redirect to "http://xxx/static/doc",

    the "http://xxx/static/doc" path be identified as a file not a dir.

    In the index.html resource "<link href="css/style.css" .../>" request "http://xxx/static/css/style.css" not "http://xxx/static/doc/css/style.css"

    how to resolve? Thank you very much!

    type:idea 
    opened by plftzk 0
  • [BUG] Serious questions about iris.withpostmaxmemory and iris.limitrequestbodysize,The connection was not disconnected when the uploaded file exceeded its capacity

    [BUG] Serious questions about iris.withpostmaxmemory and iris.limitrequestbodysize,The connection was not disconnected when the uploaded file exceeded its capacity

    platform: window10 go version: go1.16.6 windows/amd64 iris version: github.com/kataras/iris/[email protected] upload file size: 1G

    See the notes below

    Step 1: app := iris.New() app.Run( iris.Addr(fmt.Sprintf("%s:%d", "127.0.0.1", 8081)), iris.WithoutServerError(iris.ErrServerClosed), iris.WithOptimizations, iris.WithTimeFormat(time.RFC3339), // Set WithPostMaxMemory 8M iris.WithPostMaxMemory(8 << 20), );

    Step 2: // iris.LimitRequestBodySize //[BUG] There was no response and the connection was not disconnected app.Post("/upload", iris.LimitRequestBodySize(8<<20), func (ctx iris.Context) { // ... })

    or
    
    app.Post("/upload", iris.LimitRequestBodySize(8<<20), func (ctx iris.Context) {
    	maxSize := 8 << 20
    	if ctx.GetContentLength() > maxSize {
    		//[BUG] There was no response and the connection was not disconnected
    		ctx.StopWithStatus(iris.StatusRequestEntityTooLarge)
    		return
    	}
    
    	ctx.Next()
    })
    
    type:bug 
    opened by wenlng 0
  • [Suggestion] Status const named incorrectly

    [Suggestion] Status const named incorrectly

    There's a status const named iris.StatusPayloadTooRage, but meanwhile, there's another const is named "iris.StatusRequestEntityTooLarge".

    "TooRage", I think it might be named incorrectly.

    opened by XZB-1248 0
Releases(v12.2.0-alpha5)
  • v12.2.0-alpha5(Dec 2, 2021)

    What's Changed

    • Chinese translate of README.md by @iamKyun in https://github.com/kataras/iris/pull/1576
    • Update Jet dep to 5.0.2 by @Dexus in https://github.com/kataras/iris/pull/1616
    • Update pongo2 to version 4 by @kataras in https://github.com/kataras/iris/pull/1636
    • #1642: add check the values array length, avoid panic: index out of range by @aa1143 in https://github.com/kataras/iris/pull/1643
    • New JWT Middleware features and more by @kataras in https://github.com/kataras/iris/pull/1662
    • New Basic Authentication Features by @kataras in https://github.com/kataras/iris/pull/1677
    • fix the password of redis connection options by @beluxx in https://github.com/kataras/iris/pull/1686
    • fix: index of ReadJSONProtobuf options by @Jyny in https://github.com/kataras/iris/pull/1688
    • [fix _examples] response.timestamp not appear in correct request. by @cainiaoDJ in https://github.com/kataras/iris/pull/1696
    • fixed code quality issues by @withshubh in https://github.com/kataras/iris/pull/1694
    • Minor improvements and code-style fixes by @kataras in https://github.com/kataras/iris/pull/1701
    • update host.ProxyHandler to compatiable with different hosts in target url and request host by @tuhao1020 in https://github.com/kataras/iris/pull/1703
    • udpate modifyProxiedRequest by @tuhao1020 in https://github.com/kataras/iris/pull/1710
    • fix typo in https://github.com/kataras/iris/pull/1707
    • Go into myapp folder after create it by @ruannawe in https://github.com/kataras/iris/pull/1714
    • modifiy DirList's default html format by @tuhao1020 in https://github.com/kataras/iris/pull/1717
    • From Travis CI to GitHub Actions by @kataras in https://github.com/kataras/iris/pull/1729
    • bug fix #1741 #1744 by @tuhao1020 in https://github.com/kataras/iris/pull/1742
    • add CustomPathWordFunc by @yale8848 in https://github.com/kataras/iris/pull/1746
    • fix bug: #1752 by @o8x in https://github.com/kataras/iris/pull/1753
    • Update README_FA.md by @HSNHK in https://github.com/kataras/iris/pull/1766
    • fix: supper grpc and grpc web by @cq-z in https://github.com/kataras/iris/pull/1785
    • Fix panic on macos when passing a certificate as []byte to iris.TLS() by @Kimbsen in https://github.com/kataras/iris/pull/1805
    • fix: add go.mod and go.sum to allow bootstrapper compiled indepedently by @nanikjava in https://github.com/kataras/iris/pull/1800

    New Contributors

    • @iamKyun made their first contribution in https://github.com/kataras/iris/pull/1576
    • @aa1143 made their first contribution in https://github.com/kataras/iris/pull/1643
    • @beluxx made their first contribution in https://github.com/kataras/iris/pull/1686
    • @Jyny made their first contribution in https://github.com/kataras/iris/pull/1688
    • @cainiaoDJ made their first contribution in https://github.com/kataras/iris/pull/1696
    • @withshubh made their first contribution in https://github.com/kataras/iris/pull/1694
    • @tuhao1020 made their first contribution in https://github.com/kataras/iris/pull/1703
    • @ruannawe made their first contribution in https://github.com/kataras/iris/pull/1714
    • @o8x made their first contribution in https://github.com/kataras/iris/pull/1753
    • @HSNHK made their first contribution in https://github.com/kataras/iris/pull/1766
    • @cq-z made their first contribution in https://github.com/kataras/iris/pull/1785
    • @Kimbsen made their first contribution in https://github.com/kataras/iris/pull/1805
    • @nanikjava made their first contribution in https://github.com/kataras/iris/pull/1800

    Full Changelog: https://github.com/kataras/iris/compare/v12.1.8...v12.2.0-alpha5

    Source code(tar.gz)
    Source code(zip)
  • v12.2.0-alpha4(Oct 13, 2021)

    This is the forth alpha version of the upcoming version 12.2.0. Read the HISTORY.md#Next and the v12.2.0 GitHub Issues. Changes from the previous v12.2.0-alpha2 and alpha3 (Jan and September 2021): https://github.com/kataras/iris/compare/v12.2.0-alpha2...v12.2.0-alpha4.

    The code name of the v12.2.0 release is "Norbi", as the nickname of my beloved brother who died at 15 September of 2021 at the age of 27

    Source code(tar.gz)
    Source code(zip)
  • v12.2.0-alpha3(Sep 22, 2021)

    This is the third alpha version of the upcoming version 12.2.0. Read the HISTORY.md#Next and the v12.2.0 GitHub Issues. Changes from the previous v12.2.0-alpha2 (Jan 2021): https://github.com/kataras/iris/compare/v12.2.0-alpha2...v12.2.0-alpha3.

    The code name of the v12.2.0 release is "Norbi", as the nickname of my beloved brother who died at 15 September of 2021 at the age of 27

    Source code(tar.gz)
    Source code(zip)
  • v12.2.0-alpha2(Jan 10, 2021)

  • v12.2.0-alpha(Sep 13, 2020)

  • v0.0.2(Sep 3, 2020)

  • v0.0.1(Aug 12, 2020)

    You have installed an invalid version. Install with:

    go get -u github.com/kataras/iris/[email protected]
    

    If your Open Source project depends on that pre-go1.9 version please open an issue at https://github.com/kataras/iris/issues/new and share your repository with us, we will upgrade your project's code base to the latest version for free.

    If you have a commercial project that you cannot share publically, please contact with @kataras at https://chat.iris-go.com. Assistance will be provided to you and your colleagues for free.

    Source code(tar.gz)
    Source code(zip)
  • v12.1.7(Feb 10, 2020)

  • v12.1.5(Feb 2, 2020)

    Various improvements and linting. It's a generic message but please upgrade your project's Iris dependency if you had any issues serving files from subdomains or sharing dependencies through Iris controllers.

    Thanks, Gerasimos Maropoulos

    Source code(tar.gz)
    Source code(zip)
  • v12.1.4(Dec 29, 2019)

  • v12.1.1(Dec 16, 2019)

    4 new commits https://github.com/kataras/iris/compare/v12.1.0...v12.1.1

    https://github.com/kataras/iris/blob/master/HISTORY.md#mo-16-december-2019--v1211

    Source code(tar.gz)
    Source code(zip)
  • v12.1.0(Dec 13, 2019)

  • v12.0.1(Oct 26, 2019)

    • Add version suffix of the import path, learn why and see what people voted at issue #1370

    • All errors are now compatible with go1.13 errors.Is, errors.As and fmt.Errorf and a new core/errgroup package created
    • Fix #1383
    • Report whether system couldn't find the directory of view templates
    • Remove the Party#GetReport method, keep Party#GetReporter which is an error and an errgroup.Group.
    • Remove the router's deprecated methods such as StaticWeb and StaticEmbedded_XXX
    • The Context#CheckIfModifiedSince now returns an context.ErrPreconditionFailed type of error when client conditions are not met. Usage: if errors.Is(err, context.ErrPreconditionFailed) { ... }
    • Add SourceFileName and SourceLineNumber to the Route, reports the exact position of its registration inside your project's source code.
    • Fix a bug about the MVC package route binding, see PR #1364
    • Add mvc/Application#SortByNumMethods as requested at #1343
    • Add status code 103 Early Hints
    • Fix performance of session.UpdateExpiration on 200 thousands+ keys with new radix as reported at issue #1328
    • New redis session database configuration field: Driver: redis.Redigo() or redis.Radix(), see updated examples
    • Add Clusters support for redis:radix session database (Driver: redis:Radix()) as requested at issue #1339
    • Create Iranian README_FA translation with PR #1360
    • Create Korean README_KO translation with PR #1356
    • Create Spanish README_ES and HISTORY_ES translations with PR #1344.

    The iris-contrib/middleare and examples are updated to use the new github.com/kataras/iris/v12 import path.

    Source code(tar.gz)
    Source code(zip)
  • v12.0.0(Oct 26, 2019)

Owner
Gerasimos (Makis) Maropoulos
🥇 That Greek Gopher | 💨 Senior Backend Engineer at PNOĒ | 🎓My dream is to create an international IT university that will produce flawless developers!
Gerasimos (Makis) Maropoulos
Gouweb: A web framework for go inspired by laravel

gouweb is a web framework for go inspired by laravel Installation go get -u gith

null 0 Jan 20, 2022
laravel for golang,goal,fullstack framework,api framework

laravel for golang,goal,fullstack framework,api framework

桥边红药 16 Jan 12, 2022
hiboot is a high performance web and cli application framework with dependency injection support

Hiboot - web/cli application framework About Hiboot is a cloud native web and cli application framework written in Go. Hiboot is not trying to reinven

hidevops.io 162 Jan 21, 2022
re:Web enables classic web applications to run on AWS Lambda.

re:Web re:Web enables classic web applications to run on AWS Lambda. re:Web interfaces with the Lambda Runtime API. It translates API Gateway requests

null 86 Nov 20, 2021
A lightweight MVC framework for Go(Golang)

utron utron is a lightweight MVC framework in Go (Golang) for building fast, scalable and robust database-driven web applications. Features Postgres,

Geofrey Ernest 2.2k Jan 9, 2022
基于Golang的框架Gin开发,项目结构和理念参考Laravel。现支持:MySQL、Redis、MVC、拦截器、助手函数、fresh热更、swagger-UI、tpl模版输出、安全的Api。

GinLaravel的构建和运行周期与Beego、Vue、React、Laravel、ThinkPHP、Django等都会有类似的引导思路、参数设置、插件扩展、服务部署、代码统一性、生态护城河等。

方圆 31 Jan 14, 2022
Mvc+go+mysqlのrest API テンプレートリポジトリ

rest-api-temp リポジトリ概要 アドベントカレンダー用に作成 https://qiita.com/advent-calendar/2021/hcb-2021 用途 迅速にrest apiを作らなきゃいけない場合のテンプレート 注意 テンプレートAPIの使用はdocs/api.mdに記載

Takematsu 0 Dec 15, 2021
⚡ Rux is an simple and fast web framework. support middleware, compatible http.Handler interface. 简单且快速的 Go web 框架,支持中间件,兼容 http.Handler 接口

Rux Simple and fast web framework for build golang HTTP applications. NOTICE: v1.3.x is not fully compatible with v1.2.x version Fast route match, sup

Gookit 70 Jan 17, 2022
Flamingo Framework and Core Library. Flamingo is a go based framework for pluggable web projects. It is used to build scalable and maintainable (web)applications.

Flamingo Framework Flamingo is a web framework based on Go. It is designed to build pluggable and maintainable web projects. It is production ready, f

Flamingo 272 Jan 11, 2022
Golanger Web Framework is a lightweight framework for writing web applications in Go.

/* Copyright 2013 Golanger.com. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except

golanger 300 Jan 3, 2022
The jin is a simplified version of the gin web framework that can help you quickly understand the core principles of a web framework.

jin About The jin is a simplified version of the gin web framework that can help you quickly understand the core principles of a web framework. If thi

null 8 Dec 27, 2021
lightweight, idiomatic and composable router for building Go HTTP services

chi is a lightweight, idiomatic and composable router for building Go HTTP services. It's especially good at helping you write large REST API services

go-chi 10.7k Jan 13, 2022
A minimal framework to build web apps; with handler chaining, middleware support; and most of all standard library compliant HTTP handlers(i.e. http.HandlerFunc).

WebGo v4.1.3 WebGo is a minimalistic framework for Go to build web applications (server side) with zero 3rd party dependencies. Unlike full-fledged fr

Kamaleshwar 214 Jan 17, 2022
gin auto binding,grpc, and annotated route,gin 注解路由, grpc,自动参数绑定工具

中文文档 Automatic parameter binding base on go-gin doc Golang gin automatic parameter binding Support for RPC automatic mapping Support object registrati

xxj 202 Jan 18, 2022
Headless CMS with automatic JSON API. Featuring auto-HTTPS from Let's Encrypt, HTTP/2 Server Push, and flexible server framework written in Go.

Ponzu Watch the video introduction Ponzu is a powerful and efficient open-source HTTP server framework and CMS. It provides automatic, free, and secur

Ponzu 5.4k Jan 17, 2022
Data injection wrapper for values maintained in a GCP Secret Manager document.

injector The injector is a utility that retrieves a GCP Secret Manager document which contains an HJSON or JSON object with an embedded top-level envi

Mark Eissler 0 Jan 19, 2022
henrylee2cn 1.6k Jan 21, 2022
A simple blog framework built with GO. Uses HTML files and a JSON dict to give you more control over your content.

Go-Blog A simple template based blog framework. Instructions Built for GO version: 1 See the Documentation or Getting Started pages in the wiki. Notes

Matt West 44 Oct 15, 2021
Roche is a Code Generator and Web Framework, makes web development super concise with Go, CleanArch

It is still under development, so please do not use it. We plan to release v.1.0.0 in the summer. roche is a web framework optimized for microservice

Riita 11 Dec 16, 2021