All Projects → improbable-eng → Go Httpwares

improbable-eng / Go Httpwares

Licence: apache-2.0
Go HTTP Server Middleware and Client Tripperware

Programming Languages

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

Projects that are alternatives of or similar to Go Httpwares

Chi
lightweight, idiomatic and composable router for building Go HTTP services
Stars: ✭ 10,581 (+17535%)
Mutual labels:  middleware, context
Rayo.js
Micro framework for Node.js
Stars: ✭ 170 (+183.33%)
Mutual labels:  middleware, handler
Handlers
A collection of useful middleware for Go HTTP services & web applications 🛃
Stars: ✭ 1,174 (+1856.67%)
Mutual labels:  middleware, handler
Middleware
Community Middleware List for the Iris Web Framework.
Stars: ✭ 188 (+213.33%)
Mutual labels:  middleware, handler
Msngr.js
An asynchronous messaging library, written in JavaScript, for node and the web browser
Stars: ✭ 337 (+461.67%)
Mutual labels:  middleware, handler
Transmittable Thread Local
📌 TransmittableThreadLocal (TTL), the missing Java™ std lib(simple & 0-dependency) for framework/middleware, provide an enhanced InheritableThreadLocal that transmits values between threads even using thread pooling components.
Stars: ✭ 4,678 (+7696.67%)
Mutual labels:  middleware, context
Dotweb
Simple and easy go web micro framework
Stars: ✭ 1,354 (+2156.67%)
Mutual labels:  middleware, handler
Alice
Painless middleware chaining for Go
Stars: ✭ 2,438 (+3963.33%)
Mutual labels:  middleware, handler
AspNetCore.Weixin
An ASP.NET Core middleware for Wechat/Weixin message handling and apis. (微信公众平台/接口调用服务)
Stars: ✭ 24 (-60%)
Mutual labels:  middleware, handler
Serve Handler
The foundation of `serve`
Stars: ✭ 349 (+481.67%)
Mutual labels:  middleware, handler
Nex
Aiming to simplify the construction of JSON API service
Stars: ✭ 35 (-41.67%)
Mutual labels:  middleware, handler
Koa Useragent
Koa user-agent middleware
Stars: ✭ 54 (-10%)
Mutual labels:  middleware
Proxykit
A toolkit to create code-first HTTP reverse proxies on ASP.NET Core
Stars: ✭ 1,063 (+1671.67%)
Mutual labels:  middleware
Aspnetcore Request Decompression
HTTP request decompression middleware for ASP.NET Core
Stars: ✭ 51 (-15%)
Mutual labels:  middleware
Redux Query
A library for managing network state in Redux
Stars: ✭ 1,055 (+1658.33%)
Mutual labels:  middleware
Yewdux
Redux-like state containers for Yew apps
Stars: ✭ 58 (-3.33%)
Mutual labels:  context
Gin Glog
Gin middleware to use glog
Stars: ✭ 53 (-11.67%)
Mutual labels:  middleware
Dawn
🌅 Dawn is a lightweight task management and build tool for front-end and nodejs.
Stars: ✭ 1,057 (+1661.67%)
Mutual labels:  middleware
Guzzle Cache Middleware
A Guzzle Cache middleware
Stars: ✭ 50 (-16.67%)
Mutual labels:  middleware
Guzzle Stopwatch Middleware
A Guzzle Stopwatch Middleware
Stars: ✭ 50 (-16.67%)
Mutual labels:  middleware

🍲 Go HTTP Wares

Travis Build Go Report Card GoDoc SourceGraph codecov Apache 2.0 License quality: alpha

Client and Server HTTP middleware libraries leveraging Go's Context-based net/http library.

Why?

Just to clarify, these libraries are not yet another Go HTTP router, nor is it an REST client library. They are meant to interop with anything that net/http supports, without requiring much re-jigging of code.

The reason to include both server-side (middlewares) and client-side (tripperwares) is because Go HTTP servers often make HTTP requests themselves when handling an inbound request. As such, in order to make services debuggable in production, it is crucial to have the same sort of monitoring, logging and tracing available for both inbound and outbound requests. Moreover, some values (tracing, auth tokens) need to be passed from input to the output.

These libraries are meant as excellent companions for interceptors of github.com/grpc-ecosystem/go-grpc-middleware making it easy to build combined gRPC/HTTP Golang servers.

Wares

Middlewares (server-side)

Middlewares adhere to func (http.Handler) http.Handler signature. I.e. it is a handler that accept a handler.

This means that the composition purely net/http-based. This means that you can use it with echo, martini, or a home-grown router/framework of choice, worst-case you'll slide it between the http.Server and the http.Handler function of the framework.

The same composition is adopted in chi and goji, which means that you can use any middleware that's compatible with them, e.g.:

As such, this repository focuses on debugability of handlers. The crucial package here is http_ctxtags which propagates a set of key-value pairs through different middlewares in the http.Request.Context for both writing and reading. This means you get a canonical set of metadata for logging, monitoring and tracing of your inbound requests. Additionally, it allows assigning a name to a group of handlers (e.g. auth), and names to individual handlers (e.g. token_exchange).

The middlewares provided in this repo are:

  • Monitoring
  • Tracing
    • tracing/debug - /debug/request page for server-side HTTP request handling, allowing you to inspect failed requests, inbound headers etc.
    • tracing/opentracing - server-side request Opentracing middleware that is tags-aware and supports client-side propagation
  • Logging
    • logging/logrus - a Logrus-based logger for HTTP requests:
      • injects a request-scoped logrus.Entry into the http.Request.Context for further logging
      • optionally supports logging of inbound request content and response contents in raw or JSON format

Tripperware (client-side)

Tripperwares adhere to func (http.RoundTripper) http.RoundTripper signature, hence the name. As such they are used as a Transport for http.Client, and can wrap other transports.

This means that the composition is purely net/http-based. Since there are few (if any) libraries for this, the repository will have multiple useful libraries for making external calls.

The crucial package here is again http_ctxtags(tags/README.md) as it introduces a concept of a service name. This is either user-specified or automatically detected from the URL (for external calls), and is used as a key indicator in all other debugability handlers.

The tripperwares provided in this repo are:

  • Monitoring
  • Tracing
    • tracing/debug - /debug/request page for client-side HTTP request debugging, allowing you to inspect failed requests, outbound headers, payload sizes etc etc.
    • tracing/opentracing - client-side request Opentracing middleware that is tags-aware and supports propagation of traces from server-side middleware
  • Logging
    • logging/logrus - a Logrus-based logger for HTTP calls requests:
      • optionally supports logging of inbound request content and response contents in raw or JSON format
  • Retry
    • retry - a simple retry-middleware that retries on connectivity and bad response errors.

Generic building blocks

All the libraries included here are meant to be minimum-dependency based. As such the root of the package, http_wares contains helper libraries that allow for chaining and wrapping http.ResponseWriter objects. See documentation for more.

Status

This code is experimental and still considered a work in progress. It is meant to be the underpinnings of the Go HTTP stack at Improbable.

Additional tooling will be added, and contributions are welcome.

License

go-httpwares is released under the Apache 2.0 license. See the LICENSE file for details.

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].