Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Go
  3. negroni

negroni

MITGov3.1.1

A tiny, non-intrusive, idiomatic HTTP middleware library for Go that encourages use of net/http Handlers.

GitHubGitHub
7.5k stars575 forks0 contributors

What is negroni?

Negroni is an HTTP middleware library for Go that provides a clean, idiomatic way to compose middleware handlers. It solves the problem of adding cross-cutting concerns like logging, recovery, and authentication to Go web applications without forcing a full framework. By encouraging use of standard `net/http` handlers, it keeps applications simple and interoperable.

Target Audience

Go developers building web servers or APIs who need middleware functionality but want to avoid framework lock-in and prefer standard library compatibility. It's ideal for teams valuing simplicity and explicit control over their HTTP stack.

Value Proposition

Developers choose Negroni for its minimalism, zero magic, and seamless integration with Go's `net/http` package. Unlike larger frameworks, it doesn't impose routing or structure, making it perfect for projects where you want middleware without the overhead.

Overview

Idiomatic HTTP Middleware for Golang

Use Cases

Best For

  • Adding logging and panic recovery to Go HTTP servers
  • Building custom middleware stacks for API endpoints
  • Integrating third-party middleware like authentication or CORS
  • Creating route-specific middleware groups in large applications
  • Learning HTTP middleware patterns in Go without framework complexity
  • Migrating from Martini to a simpler, less magical middleware solution

Not Ideal For

  • Projects needing built-in routing, templating, or database ORM without additional libraries
  • Teams preferring convention-over-configuration frameworks like Gin or Echo for rapid development
  • Applications requiring advanced features like WebSocket handling or real-time updates out of the box
  • Environments where middleware abstraction adds unnecessary complexity for simple HTTP servers

Pros & Cons

Pros

Minimal API Surface

Negroni's tiny, non-intrusive design avoids forcing a specific application structure, as emphasized in the README's philosophy of doing one thing well with minimal magic.

Standard Library Compatibility

It works seamlessly with any router or handler implementing the standard net/http interface, ensuring broad interoperability and avoiding vendor lock-in, as shown in integration examples with Gorilla Mux.

Bidirectional Middleware Flow

Middleware can execute logic both before and after the next handler via the Handler interface, enabling flexible request/response manipulation, as demonstrated in the ServeHTTP examples.

Useful Defaults

negroni.Classic() provides ready-to-use middleware for recovery, logging, and static file serving, reducing initial setup time for common web server needs.

Third-Party Ecosystem

A wide range of community-built middleware is compatible, listed in the README for authentication, monitoring, and more, extending functionality without reinventing the wheel.

Cons

No Built-in Routing

Negroni requires developers to bring their own router (BYOR), adding setup complexity and dependency management for basic routing needs, as admitted in the 'Routing?' section.

Limited Core Functionality

Out of the box, it only includes basic middleware like recovery and logging; advanced features such as authentication or compression rely on third-party libraries, which can vary in quality and maintenance.

Middleware Chain Verbosity

Managing multiple Negroni instances for route-specific middleware, as shown in examples, can lead to verbose and error-prone code in large applications with complex routing hierarchies.

Frequently Asked Questions

Quick Stats

Stars7,526
Forks575
Contributors0
Open Issues6
Last commit1 day ago
CreatedSince 2014

Tags

#net-http#http-middleware#server-side#api-development#web-framework#go

Built With

G
Go

Included in

Go169.1k
Auto-fetched 15 hours ago

Related Projects

alicealice

Painless middleware chaining for Go

Stars3,362
Forks152
Last commit2 years ago
renderrender

Go package for easily rendering JSON, XML, binary data, and HTML templates responses.

Stars1,997
Forks151
Last commit2 months ago
statsstats

A Go middleware that stores various information about your web application (response time, status code count, etc.)

Stars594
Forks50
Last commit3 years ago
interposeinterpose

Minimalist net/http middleware for golang

Stars291
Forks16
Last commit9 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub