Popularity
0.8
Declining
Activity
0.0
Stable
8
1
0

Programming language: Go
License: MIT License
Latest version: v1.6.1

easy-middleware alternatives and similar packages

Based on the "Actual middlewares" category.
Alternatively, view easy-middleware alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of easy-middleware or a related project?

Add another 'Actual middlewares' Package

README

Build Status

easy-middleware

What is easy-middleware ?

easy-middleware is a lightweight json middleware stack for Go >= 1.7.

Features:

  • Dump incoming request middleware
  • Set body limit middleware
  • Json header check middleware
  • Validator middleware
  • Sql db middleware
  • Recovery middleware
  • With value middleware
  • Json response writer middleware

Feature request are welcome

Example :

    package main

    import (
        "net/http"
        "github.com/donutloop/easy-middleware"
    )

    func main() {

        stack := easy_middleware.New()
        stack.Add(easy_middleware.Json())
        stack.Add(easy_middleware.SqlDb("postgres", "postgres://postgres:[email protected]/postgres?sslmode=disable"))

        http.Handle("/user", stack.Then(http.HandlerFunc(userHandler)))
        http.ListenAndServe(":80", nil)
    }

    func userHandler(rw http.ResponseWriter, req *http.Request) {
         jrw := rw.(*easy_middleware.JsonResponseWriter)          

         var db *sql.DB
         if rv := r.Context().Value("db"); rv != nil {
                if v, ok := rv.(*sql.DB); ok {
                     db = v 
                } else if err := rv.(*easy_middleware.DatabaseError); err != nil {
                     jrw.WriteError(err, http.StatusInternalServerError)
                     return 
                }
         }  
        //...

    }

More documentation comming soon