Back to Iris

README

middleware/README.md

12.2.116.5 KB
Original Source

Builtin Handlers

MiddlewareExample
rewriteiris/_examples/routing/rewrite
basic authenticationiris/_examples/auth/basicauth
request loggeriris/_examples/logging/request-logger
HTTP method overrideiris/middleware/methodoverride/methodoverride_test.go
profiling (pprof)iris/_examples/pprof
Google reCAPTCHAiris/_examples/auth/recaptcha
hCaptchairis/_examples/auth/recaptcha
recoveryiris/_examples/recover
rateiris/_examples/request-ratelimit
jwtiris/_examples/auth/jwt
requestidiris/middleware/requestid/requestid_test.go

Community made

Most of the experimental handlers are ported to work with iris's handler form, from third-party sources.

MiddlewareDescriptionExample
pgMiddleware that provides easy and type-safe access to PostgreSQL databaseiris-contrib/middleware/pg/_examples
jwtMiddleware checks for a JWT on the Authorization header on incoming requests and decodes itiris-contrib/middleware/jwt/_example
corsHTTP Access Controliris-contrib/middleware/cors/_example
secureMiddleware that implements a few quick security winsiris-contrib/middleware/secure/_example
tollboothGeneric middleware to rate-limit HTTP requestsiris-contrib/middleware/tollboothic/_examples/limit-handler
cloudwatchAWS cloudwatch metrics middlewareiris-contrib/middleware/cloudwatch/_example
new relicOfficial New Relic Go Agentiris-contrib/middleware/newrelic/_example
prometheusEasily create metrics endpoint for the prometheus instrumentation tooliris-contrib/middleware/prometheus/_example
casbinAn authorization library that supports access control models like ACL, RBAC, ABACiris-contrib/middleware/casbin/_examples
sentry-go (ex. raven)Sentry client in Gosentry-go/example/iris
csrfCross-Site Request Forgery Protectioniris-contrib/middleware/csrf/_example
throttlerRate limiting access to HTTP endpointsiris-contrib/middleware/throttler/_example

Third-Party Handlers

Iris has its own middleware form of func(ctx iris.Context) but it's also compatible with all net/http middleware forms. See here.

Here's a small list of useful third-party handlers:

MiddlewareDescription
gothOAuth, OAuth2 authentication. Example
permissions2Cookies, users and permissions. Example
cspContent Security Policy (CSP) support
delayAdd delays/latency to endpoints. Useful when testing effects of high latency
ontheflyGenerate TinySVG, HTML and CSS on the fly
RestGateSecure authentication for REST API endpoints
statsStore information about your web application (response time, etc.)
VanGoHConfigurable AWS-Style HMAC authentication middleware
digitsMiddleware that handles Twitter Digits authentication

Feel free to put up your own middleware in this list!