A great set of helper middleware and functionality  for Golang Chi Library


chix — helper middleware and functionality for go-chi/chi

link Table of Contents

  • Usage
  • Features
  • Support & Assistance
  • Contributing
  • License

Go Library Usage

go get -u github.com/lrstanley/chix@latest

Golang Library Features

  • http.Server wrapper that easily allows starting and gracefully shutting down your http server, and other background services, using errgroup.
  • RealIP middleware (supports whitelisting specific proxies, rather than allowing any source).
  • Rendering helpers:JSON (with ?pretty=true support).
  • Auth middleware:Uses markbates/goth to support many different providers.
  • Encrypts session cookies, which removes the need for local session storage.
  • Uses Golang 1.18’s generics functionality to provide a custom ID and auth object resolver.No longer have to type assert to your local models!
  • Optionally requiring authentication.
  • Optionally requiring specific roles.
  • Optionally adding authentication info to context for use by children handlers.
  • API key validation.
  • API version validation.
  • private IP middleware, restricting endpoints to be internal only.
  • Struct/type binding, from get/post data, with support for go-playground/validator.
  • Structured logging using apex/log (same API as logrus).
    • Allows injecting additional metadata into logs.
    • Injects logger into context for use by children handlers.
  • Debug middleware:
    • Easily let children handlers know if global debug flags are enabled.
    • Allows masking errors, unless debugging is enabled.
  • Error handler, that automatically handles api-vs-static content responses.
    • Supports ErrorResolver‘s, providing the ability to override status codes for specific types of errors.
  • go:embed helpers for mounting an embedded filesystem seamlessly as an http endpoint.
    • Useful for projects that bundle their frontend assets in their binary.
    • Supports local filesystem reading, when debugging is enabled (TODO).
  • Middleware for robots.txt and security.txt responding.

Support & Assistance

  • heart Please review the Code of Conduct for guidelines on ensuring everyone has the best experience interacting with the community.
  • raising_hand_man Take a look at the support document on guidelines for tips on how to ask the right questions.
  • lady_beetle For all features/bugs/issues/questions/etc, head over here.

Contributing to this Golang Library

  • heart Please review the Code of Conduct for guidelines on ensuring everyone has the best experience interacting with the community.
  • clipboard Please review the contributing doc for submitting issues/a guide on submitting pull requests and helping out.
  • old_key For anything security related, please review this repositories security policy.

License

MIT License

Copyright (c) 2022 Liam Stanley <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Also located here