- Notifications
You must be signed in to change notification settings - Fork1
helper middleware and functionality for go-chi/chi
License
NotificationsYou must be signed in to change notification settings
lrstanley/chix
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
go get -u github.com/lrstanley/chix@latest
http.Server
wrapper that easily allows starting, and gracefully shuttingdown your http server, and other background services, usingerrgroup
.- RealIP middleware (supports whitelisting specific proxies, rather than allowingany source).
- private IP middleware, restricting endpoints to be internal only.
- Rendering helpers:
JSON
(with?pretty=true
support).
- Auth middleware:
- Usesmarkbates/goth to support manydifferent providers.
- Encrypts session cookies, which removes the need for local session storage.
- Uses Go 1.18's generics functionality to provide a custom ID and auth objectresolver.
- 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.
- Struct/type binding, from get/post data, with support forgo-playground/validator.
- Structured logging usingapex/log (same APIas 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 codesfor specific types of errors.
- Supports
go:embed
helpers for mounting an embedded filesystem seamlessly as an httpendpoint.- 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.
- lrstanley/clix -- go-flags wrapper, thathandles parsing and decoding, with additional helpers.
- lrstanley/go-query-parser -- similarto that of Google/Github/etc search, a query string parser that allows filtersand tags to be dynamically configured by the end user.
Use these as a reference point for how you might use some of the functionality withinthis library, or how you might want to structure your applications.
- ❤️ Please review theCode of Conduct forguidelines on ensuring everyone has the best experience interacting withthe community.
- 🙋♂️ Take a look at thesupport document onguidelines for tips on how to ask the right questions.
- 🐞 For all features/bugs/issues/questions/etc,head over here.
- ❤️ Please review theCode of Conduct for guidelineson ensuring everyone has the best experience interacting with thecommunity.
- 📋 Please review thecontributing doc for submittingissues/a guide on submitting pull requests and helping out.
- 🗝️ For anything security related, please review this repositoriessecurity policy.
MIT LicenseCopyright (c) 2022 Liam Stanley <liam@liam.sh>Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, 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 THESOFTWARE.
Also locatedhere
About
helper middleware and functionality for go-chi/chi