All Projects → iris-contrib → Middleware

iris-contrib / Middleware

Community Middleware List for the Iris Web Framework.

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Middleware

Handlers
A collection of useful middleware for Go HTTP services & web applications 🛃
Stars: ✭ 1,174 (+524.47%)
Mutual labels:  middleware, handler
Alice
Painless middleware chaining for Go
Stars: ✭ 2,438 (+1196.81%)
Mutual labels:  middleware, handler
Rayo.js
Micro framework for Node.js
Stars: ✭ 170 (-9.57%)
Mutual labels:  middleware, handler
Msngr.js
An asynchronous messaging library, written in JavaScript, for node and the web browser
Stars: ✭ 337 (+79.26%)
Mutual labels:  middleware, handler
Nex
Aiming to simplify the construction of JSON API service
Stars: ✭ 35 (-81.38%)
Mutual labels:  middleware, handler
Serve Handler
The foundation of `serve`
Stars: ✭ 349 (+85.64%)
Mutual labels:  middleware, handler
AspNetCore.Weixin
An ASP.NET Core middleware for Wechat/Weixin message handling and apis. (微信公众平台/接口调用服务)
Stars: ✭ 24 (-87.23%)
Mutual labels:  middleware, handler
Go Httpwares
Go HTTP Server Middleware and Client Tripperware
Stars: ✭ 60 (-68.09%)
Mutual labels:  middleware, handler
Dotweb
Simple and easy go web micro framework
Stars: ✭ 1,354 (+620.21%)
Mutual labels:  middleware, handler
Nevercrash
🌍 全局捕获Crash。信NeverCrash,永不Crash。
Stars: ✭ 170 (-9.57%)
Mutual labels:  handler
Micro Aws Lambda
A 7KB and 0 dependencies AWS Lambda library which supports middleware and easy debug.
Stars: ✭ 181 (-3.72%)
Mutual labels:  middleware
Gutenberg Fields Middleware
Register fields for Gutenberg blocks with less repetitive code
Stars: ✭ 167 (-11.17%)
Mutual labels:  middleware
Awesome Community Curated Nlp
Community Curated NLP List
Stars: ✭ 173 (-7.98%)
Mutual labels:  community-driven
Middy
🛵 The stylish Node.js middleware engine for AWS Lambda
Stars: ✭ 2,592 (+1278.72%)
Mutual labels:  middleware
Ego
Ego is a full-stack web framework written in Go, lightweight and efficient front-end component solutions, based on gin. The front-end is compiled, does not affect the back-end.
Stars: ✭ 185 (-1.6%)
Mutual labels:  middleware
Http Swagger
Default net/http wrapper to automatically generate RESTful API documentation with Swagger 2.0.
Stars: ✭ 166 (-11.7%)
Mutual labels:  middleware
Laravel Rate Limited Job Middleware
A job middleware to rate limit jobs
Stars: ✭ 166 (-11.7%)
Mutual labels:  middleware
Lightify
a reverse proxy that boosts the web app performance!
Stars: ✭ 187 (-0.53%)
Mutual labels:  middleware
Vue Gates
🔒 A Vue.js & Nuxt.js plugin that allows you to use roles and permissions in your components or DOM elements, also compatible as middleware and methods.
Stars: ✭ 184 (-2.13%)
Mutual labels:  middleware
Csurf
CSRF token middleware
Stars: ✭ 2,183 (+1061.17%)
Mutual labels:  middleware

Iris Community Middleware List

This repository provides a way to share community-based middlewares for Iris v12.2.0+ (currently master branch). Among with those, you can also navigate through the builtin Iris handlers.

Installation

Install a middleware, take for example the jwt one.

$ go env -w GOPROXY=goproxy.cn,gocenter.io,goproxy.io,direct
$ go mod init myapp
$ go get github.com/kataras/iris/[email protected]
$ go get github.com/iris-contrib/middleware/[email protected]

import as

import "github.com/iris-contrib/middleware/jwt"

// [...Code]

build

$ go build

Middleware is just a chain handlers which can be executed before or after the main handler, can transfer data between handlers and communicate with third-party libraries, they are just functions.

Middleware Description Example
jwt JSON Web Tokens jwt
cors HTTP Access Control. cors/_example
secure Middleware that implements a few quick security wins secure/_example
tollbooth Generic middleware to rate-limit HTTP requests tollboothic/_examples/limit-handler
cloudwatch AWS cloudwatch metrics middleware cloudwatch/_example
newrelic/v3 Official New Relic Go Agent newrelic/_example
prometheus Easily create metrics endpoint for the prometheus instrumentation tool prometheus/_example
casbin An authorization library that supports access control models like ACL, RBAC, ABAC casbin/_examples
sentry-go (ex. raven) Sentry client in Go sentry-go/example/iris
csrf Cross-Site Request Forgery Protection csrf/_example
throttler Rate limiting access to HTTP endpoints throttler/_example

Register a middleware

To a single route

app := iris.New()
app.Get("/mypath",
  onBegin,
  mySecondMiddleware,
  mainHandler,
)

func onBegin(ctx iris.Context) { /* ... */ ctx.Next() }
func mySecondMiddleware(ctx iris.Context) { /* ... */ ctx.Next() }
func mainHandler(ctx iris.Context) { /* ... */ }

To a party of routes or subdomain


p := app.Party("/sellers", authMiddleware, logMiddleware)

OR

p := app.Party("/customers")
p.Use(logMiddleware)

To all routes

app.Use(func(ctx iris.Context) { }, myMiddleware2)

To global, all registered routes (including the http errors)

app.UseGlobal(func(ctx iris.Context) { }, myMiddleware2)

To Party and its children, even on unmatched routes and errors

app.UseRouter(func(ctx iris.Context) { }, myMiddleware2))

Can I use standard net/http handler with iris?

Yes you can, just pass the Handler inside the iris.FromStd in order to be converted into iris.Handler and register it as you saw before.

Convert handler which has the form of http.Handler/HandlerFunc

package main

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

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

    sillyHTTPHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request){
            println(r.RequestURI)
    })

    sillyConvertedToIon := iris.FromStd(sillyHTTPHandler)
    // FromStd can take (http.ResponseWriter, *http.Request, next http.Handler) too!
    app.Use(sillyConvertedToIon)

    app.Listen(":8080")
}

Contributing

If you are interested in contributing to this project, please push a PR.

People

List of all contributors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].