Skip to content

Commit 9ee9f7e

Browse files
committed
add named handlers for iris-contrib middleware too
1 parent f833d7f commit 9ee9f7e

File tree

10 files changed

+52
-3
lines changed

10 files changed

+52
-3
lines changed

casbin/casbin.go

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"net/http"
55

66
"github.com/kataras/iris/v12"
7+
"github.com/kataras/iris/v12/context"
78

89
"github.com/casbin/casbin/v2"
910
)
@@ -13,6 +14,10 @@ import (
1314
2020-08-08
1415
*/
1516

17+
func init() {
18+
context.SetHandlerName("github.com/iris-contrib/middleware/casbin.*", "iris-contrib.casbin")
19+
}
20+
1621
// New returns the auth service which receives a casbin enforcer.
1722
//
1823
// Adapt with its `Wrapper` for the entire application

cloudwatch/cloudwatch.go

+5
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ import (
55
"time"
66

77
"github.com/kataras/iris/v12"
8+
"github.com/kataras/iris/v12/context"
89

910
"github.com/aws/aws-sdk-go/aws"
1011
"github.com/aws/aws-sdk-go/aws/awserr"
1112
"github.com/aws/aws-sdk-go/aws/session"
1213
"github.com/aws/aws-sdk-go/service/cloudwatch"
1314
)
1415

16+
func init() {
17+
context.SetHandlerName("github.com/iris-contrib/middleware/cloudwatch.*", "iris-contrib.cloudwatch")
18+
}
19+
1520
// PutMetricContextKey is the context key which the metrics are stored.
1621
const PutMetricContextKey = "PUT_METRIC"
1722

cors/cors.go

+5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@ import (
88
"strings"
99

1010
"github.com/kataras/iris/v12"
11+
"github.com/kataras/iris/v12/context"
1112
)
1213

14+
func init() {
15+
context.SetHandlerName("github.com/iris-contrib/middleware/cors.*", "iris-contrib.cors")
16+
}
17+
1318
// Options is a configuration container to setup the CORS middleware.
1419
type Options struct {
1520
// AllowedOrigins is a list of origins a cross-domain request can be executed from.

csrf/csrf.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
func init() {
14-
context.SetHandlerName("github.com/iris-contrib/middleware/csrf.*", "iris.csrf.token")
14+
context.SetHandlerName("github.com/iris-contrib/middleware/csrf.*", "iris-contrib.csrf.token")
1515
}
1616

1717
// CSRF token length in bytes.

jwt/jwt.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@ import (
66
"strings"
77
"time"
88

9-
"github.com/dgrijalva/jwt-go"
109
"github.com/kataras/iris/v12"
10+
"github.com/kataras/iris/v12/context"
11+
12+
"github.com/dgrijalva/jwt-go"
1113
)
1214

15+
func init() {
16+
context.SetHandlerName("github.com/iris-contrib/middleware/jwt.*", "iris-contrib.jwt")
17+
}
18+
1319
type (
1420
// Token for JWT. Different fields will be used depending on whether you're
1521
// creating or parsing/verifying a token.

newrelic/newrelic.go

+6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@ import (
44
"time"
55

66
"github.com/kataras/iris/v12"
7+
"github.com/kataras/iris/v12/context"
8+
79
"github.com/newrelic/go-agent/v3/newrelic"
810
)
911

12+
func init() {
13+
context.SetHandlerName("github.com/iris-contrib/middleware/newrelic.*", "iris-contrib.newrelic")
14+
}
15+
1016
// Migration from newrelic to newrelic/v3:
1117
// https://github.com/newrelic/go-agent/blob/master/MIGRATION.md#configuration
1218

prometheus/prometheus.go

+6
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ import (
55
"time"
66

77
"github.com/kataras/iris/v12"
8+
"github.com/kataras/iris/v12/context"
9+
810
"github.com/prometheus/client_golang/prometheus"
911
)
1012

13+
func init() {
14+
context.SetHandlerName("github.com/iris-contrib/middleware/prometheus.*", "iris-contrib.prometheus")
15+
}
16+
1117
var (
1218
// DefaultBuckets prometheus buckets in seconds.
1319
DefaultBuckets = []float64{0.3, 1.2, 5.0}

secure/csp.go

+5
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ import (
66
"io"
77

88
"github.com/kataras/iris/v12"
9+
"github.com/kataras/iris/v12/context"
910
)
1011

12+
func init() {
13+
context.SetHandlerName("github.com/iris-contrib/middleware/secure.*", "iris-contrib.secure")
14+
}
15+
1116
const cspNonceKey string = "iris.secure.nonce"
1217

1318
// CSPNonce returns the nonce value associated with the present request. If no nonce has been generated it returns an empty string.

throttler/throttler.go

+5
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ import (
77
"strconv"
88

99
"github.com/kataras/iris/v12"
10+
"github.com/kataras/iris/v12/context"
1011

1112
"github.com/throttled/throttled/v2"
1213
)
1314

15+
func init() {
16+
context.SetHandlerName("github.com/iris-contrib/middleware/throttler.*", "iris-contrib.throttler")
17+
}
18+
1419
var (
1520
// DefaultDeniedHandler is the default DeniedHandler for an
1621
// RateLimiter. It returns a 429 status code with a generic

tollboothic/tollboothic.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22
package tollboothic
33

44
import (
5+
"github.com/kataras/iris/v12"
6+
"github.com/kataras/iris/v12/context"
7+
58
"github.com/didip/tollbooth/v6"
69
"github.com/didip/tollbooth/v6/limiter"
7-
"github.com/kataras/iris/v12"
810
)
911

12+
func init() {
13+
context.SetHandlerName("github.com/iris-contrib/middleware/tollboothic.*", "iris-contrib.tollboothic")
14+
}
15+
1016
// LimitHandler is a middleware that performs
1117
// rate-limiting given a "limiter" configuration.
1218
//

0 commit comments

Comments
 (0)