Update linter

This commit is contained in:
Tom Moulard 2022-07-19 18:38:09 +02:00 committed by GitHub
parent b361608693
commit 7751fb24eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 63 additions and 51 deletions

View file

@ -48,10 +48,10 @@ func (c Chain) Then(h Handler) (Handler, error) {
//
// Append returns a new chain, leaving the original one untouched.
//
// stdChain := tcp.NewChain(m1, m2)
// extChain := stdChain.Append(m3, m4)
// // requests in stdChain go m1 -> m2
// // requests in extChain go m1 -> m2 -> m3 -> m4
// stdChain := tcp.NewChain(m1, m2)
// extChain := stdChain.Append(m3, m4)
// // requests in stdChain go m1 -> m2
// // requests in extChain go m1 -> m2 -> m3 -> m4
func (c Chain) Append(constructors ...Constructor) Chain {
newCons := make([]Constructor, 0, len(c.constructors)+len(constructors))
newCons = append(newCons, c.constructors...)
@ -65,22 +65,23 @@ func (c Chain) Append(constructors ...Constructor) Chain {
//
// Extend returns a new chain, leaving the original one untouched.
//
// stdChain := tcp.NewChain(m1, m2)
// ext1Chain := tcp.NewChain(m3, m4)
// ext2Chain := stdChain.Extend(ext1Chain)
// // requests in stdChain go m1 -> m2
// // requests in ext1Chain go m3 -> m4
// // requests in ext2Chain go m1 -> m2 -> m3 -> m4
// stdChain := tcp.NewChain(m1, m2)
// ext1Chain := tcp.NewChain(m3, m4)
// ext2Chain := stdChain.Extend(ext1Chain)
// // requests in stdChain go m1 -> m2
// // requests in ext1Chain go m3 -> m4
// // requests in ext2Chain go m1 -> m2 -> m3 -> m4
//
// Another example:
// aHtmlAfterNosurf := tcp.NewChain(m2)
// aHtml := tcp.NewChain(m1, func(h tcp.Handler) tcp.Handler {
// csrf := nosurf.New(h)
// csrf.SetFailureHandler(aHtmlAfterNosurf.ThenFunc(csrfFail))
// return csrf
// }).Extend(aHtmlAfterNosurf)
// // requests to aHtml hitting nosurfs success handler go m1 -> nosurf -> m2 -> target-handler
// // requests to aHtml hitting nosurfs failure handler go m1 -> nosurf -> m2 -> csrfFail
//
// aHtmlAfterNosurf := tcp.NewChain(m2)
// aHtml := tcp.NewChain(m1, func(h tcp.Handler) tcp.Handler {
// csrf := nosurf.New(h)
// csrf.SetFailureHandler(aHtmlAfterNosurf.ThenFunc(csrfFail))
// return csrf
// }).Extend(aHtmlAfterNosurf)
// // requests to aHtml hitting nosurfs success handler go m1 -> nosurf -> m2 -> target-handler
// // requests to aHtml hitting nosurfs failure handler go m1 -> nosurf -> m2 -> csrfFail
func (c Chain) Extend(chain Chain) Chain {
return c.Append(chain.constructors...)
}