-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement `go-middlewares` * Update `README.md` * Update `CHANGELOG.md` * Update `README.md`
- Loading branch information
1 parent
32d6be0
commit 552b20c
Showing
24 changed files
with
666 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
name: "🐛 Bug Report" | ||
about: Report a reproducible bug or regression. | ||
title: 'Bug: ' | ||
labels: 'bug' | ||
|
||
--- | ||
|
||
<!-- | ||
Please provide a clear and concise description of what the bug is. Include | ||
screenshots if needed. Please test using the latest version of the relevant | ||
React packages to make sure your issue has not already been fixed. | ||
--> | ||
|
||
Application version: | ||
|
||
## Steps To Reproduce | ||
|
||
1. | ||
2. | ||
|
||
<!-- | ||
Your bug will get fixed much faster if we can run your code and it doesn't | ||
have dependencies other than React. Issues without reproduction steps or | ||
code examples may be immediately closed as not actionable. | ||
--> | ||
|
||
Link to code example: | ||
|
||
<!-- | ||
Please provide a CodeSandbox (https://codesandbox.io/s/new), a link to a | ||
repository on GitHub, or provide a minimal code example that reproduces the | ||
problem. You may provide a screenshot of the application if you think it is | ||
relevant to your bug report. Here are some tips for providing a minimal | ||
example: https://stackoverflow.com/help/mcve. | ||
--> | ||
|
||
## The current behavior | ||
|
||
|
||
## The expected behavior |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
name: 🛠 Feature request | ||
about: If you have a feature request for the go-middlewares, file it here. | ||
labels: 'type: enhancement' | ||
--- | ||
|
||
**Feature description** | ||
Clearly and concisely describe the feature. | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## Bug description | ||
Clearly and concisely describe the problem. | ||
|
||
## Solution description | ||
Describe your code changes in detail for reviewers. Explain the technical solution you have provided and how it fixes the issue case. | ||
|
||
## Covered unit test cases | ||
- [x] yes | ||
- [x] no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
## Feature description | ||
Clearly and concisely describe the feature. | ||
|
||
## Solution description | ||
Describe your code changes in detail for reviewers. | ||
|
||
## Areas affected and ensured | ||
List out the areas affected by your code changes. | ||
|
||
## Covered unit test cases | ||
- [x] yes | ||
- [x] no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: go_middlewares | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.19 | ||
- name: Build | ||
run: go build -v ./... | ||
- name: Test | ||
run: go test -v ./... -coverprofile=coverage.out -covermode=atomic | ||
- name: Upload coverage to Codecov | ||
uses: codecov/[email protected] | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Danger | ||
|
||
on: | ||
pull_request: | ||
types: [synchronize, opened, reopened, labeled, unlabeled, edited] | ||
|
||
env: | ||
LC_CTYPE: en_US.UTF-8 | ||
LANG: en_US.UTF-8 | ||
|
||
jobs: | ||
run-danger: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: ruby setup | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.7 | ||
bundler-cache: true | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Setup gems | ||
run: | | ||
gem install bundler | ||
bundle install --clean --path vendor/bundle | ||
- name: danger | ||
env: | ||
DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }} | ||
run: bundle exec danger --verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.3.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- id: check-added-large-files | ||
- repo: https://github.com/dnephin/pre-commit-golang | ||
rev: v0.5.0 | ||
hooks: | ||
- id: go-fmt | ||
- id: go-imports | ||
- id: no-go-testing | ||
- id: golangci-lint | ||
- id: go-unit-tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
brew "golangci-lint" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"entries": { | ||
"brew": { | ||
"golangci-lint": { | ||
"version": "1.55.1", | ||
"bottle": { | ||
"rebuild": 0, | ||
"root_url": "https://ghcr.io/v2/homebrew/core", | ||
"files": { | ||
"arm64_sonoma": { | ||
"cellar": ":any_skip_relocation", | ||
"url": "https://ghcr.io/v2/homebrew/core/golangci-lint/blobs/sha256:9d538964526454d4f8b1ab095bf601bd43fab37f95d4d52fca5d4a012cd2a2df", | ||
"sha256": "9d538964526454d4f8b1ab095bf601bd43fab37f95d4d52fca5d4a012cd2a2df" | ||
}, | ||
"arm64_ventura": { | ||
"cellar": ":any_skip_relocation", | ||
"url": "https://ghcr.io/v2/homebrew/core/golangci-lint/blobs/sha256:f8a3588e7823345d134095988cfcbe69826e912cad50fea2ffaad16b7cfe5e6b", | ||
"sha256": "f8a3588e7823345d134095988cfcbe69826e912cad50fea2ffaad16b7cfe5e6b" | ||
}, | ||
"arm64_monterey": { | ||
"cellar": ":any_skip_relocation", | ||
"url": "https://ghcr.io/v2/homebrew/core/golangci-lint/blobs/sha256:db8b11f44eb2151c60d163a85efaeeb27f4887b0e0d1418d35e451cda446360f", | ||
"sha256": "db8b11f44eb2151c60d163a85efaeeb27f4887b0e0d1418d35e451cda446360f" | ||
}, | ||
"sonoma": { | ||
"cellar": ":any_skip_relocation", | ||
"url": "https://ghcr.io/v2/homebrew/core/golangci-lint/blobs/sha256:1bbdd91bf065e905320c51e050aaaa5cf41386acb896d3f4704e8940a8f323e3", | ||
"sha256": "1bbdd91bf065e905320c51e050aaaa5cf41386acb896d3f4704e8940a8f323e3" | ||
}, | ||
"ventura": { | ||
"cellar": ":any_skip_relocation", | ||
"url": "https://ghcr.io/v2/homebrew/core/golangci-lint/blobs/sha256:b9c815da27c6b3533fcbb84b3cd223dece6e7b740a3ac6c76532715e232e0490", | ||
"sha256": "b9c815da27c6b3533fcbb84b3cd223dece6e7b740a3ac6c76532715e232e0490" | ||
}, | ||
"monterey": { | ||
"cellar": ":any_skip_relocation", | ||
"url": "https://ghcr.io/v2/homebrew/core/golangci-lint/blobs/sha256:a7aad3d6901a2f70fe9a87167245ca09bb1e1de1d938c0ce1ba5cb7587500311", | ||
"sha256": "a7aad3d6901a2f70fe9a87167245ca09bb1e1de1d938c0ce1ba5cb7587500311" | ||
}, | ||
"x86_64_linux": { | ||
"cellar": ":any_skip_relocation", | ||
"url": "https://ghcr.io/v2/homebrew/core/golangci-lint/blobs/sha256:e6270eb1a19cc1d7002d054533a8aeded82fedbc49d17c8909efd5b4f0418a43", | ||
"sha256": "e6270eb1a19cc1d7002d054533a8aeded82fedbc49d17c8909efd5b4f0418a43" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"system": { | ||
"macos": { | ||
"ventura": { | ||
"HOMEBREW_VERSION": "4.1.16", | ||
"HOMEBREW_PREFIX": "/usr/local", | ||
"Homebrew/homebrew-core": "api", | ||
"CLT": "", | ||
"Xcode": "14.1", | ||
"macOS": "13.4" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Change Log | ||
All notable changes to this project will be documented in this file. | ||
|
||
#### 1.x Releases | ||
- `1.0.x` Releases - [1.0.0](#100) | ||
|
||
## [1.0.0](https://github.com/space-code/go-middlewares/releases/tag/1.0.0) | ||
Released on 2023-11-02. | ||
|
||
#### Added | ||
- Initial release of go-middlewares. | ||
- Added by [Nikita Vasilev](https://github.com/nik3212). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
danger.import_dangerfile(github: 'space-code/dangerfile') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source "https://rubygems.org" | ||
|
||
gem 'danger' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
addressable (2.8.5) | ||
public_suffix (>= 2.0.2, < 6.0) | ||
base64 (0.1.1) | ||
claide (1.1.0) | ||
claide-plugins (0.9.2) | ||
cork | ||
nap | ||
open4 (~> 1.3) | ||
colored2 (3.1.2) | ||
cork (0.3.0) | ||
colored2 (~> 3.1) | ||
danger (9.3.2) | ||
claide (~> 1.0) | ||
claide-plugins (>= 0.9.2) | ||
colored2 (~> 3.1) | ||
cork (~> 0.1) | ||
faraday (>= 0.9.0, < 3.0) | ||
faraday-http-cache (~> 2.0) | ||
git (~> 1.13) | ||
kramdown (~> 2.3) | ||
kramdown-parser-gfm (~> 1.0) | ||
no_proxy_fix | ||
octokit (~> 6.0) | ||
terminal-table (>= 1, < 4) | ||
faraday (2.7.11) | ||
base64 | ||
faraday-net_http (>= 2.0, < 3.1) | ||
ruby2_keywords (>= 0.0.4) | ||
faraday-http-cache (2.5.0) | ||
faraday (>= 0.8) | ||
faraday-net_http (3.0.2) | ||
git (1.18.0) | ||
addressable (~> 2.8) | ||
rchardet (~> 1.8) | ||
kramdown (2.4.0) | ||
rexml | ||
kramdown-parser-gfm (1.1.0) | ||
kramdown (~> 2.0) | ||
nap (1.1.0) | ||
no_proxy_fix (0.1.2) | ||
octokit (6.1.1) | ||
faraday (>= 1, < 3) | ||
sawyer (~> 0.9) | ||
open4 (1.3.4) | ||
public_suffix (5.0.3) | ||
rchardet (1.8.0) | ||
rexml (3.2.6) | ||
ruby2_keywords (0.0.5) | ||
sawyer (0.9.2) | ||
addressable (>= 2.3.5) | ||
faraday (>= 0.17.3, < 3) | ||
terminal-table (3.0.2) | ||
unicode-display_width (>= 1.1.1, < 3) | ||
unicode-display_width (2.5.0) | ||
|
||
PLATFORMS | ||
x86_64-darwin-22 | ||
|
||
DEPENDENCIES | ||
danger | ||
|
||
BUNDLED WITH | ||
2.4.21 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,67 @@ | ||
# go-middlewares | ||
<h1 align="center" style="margin-top: 0px;">go-middlewares</h1> | ||
|
||
<p align="center"> | ||
<a href="https://github.com/space-code/go-middlewares/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/badge/License-MIT-yellow.svg"></a> | ||
<a href="https://github.com/space-code/go-middlewares"><img alt="CI" src="https://github.com/space-code/go-middlewares/actions/workflows/ci.yml/badge.svg?branch=main"></a> | ||
</p> | ||
|
||
## Description | ||
`go-middlewares` is a collection of commonly used middlewares in Go. | ||
|
||
- [Usage](#usage) | ||
- [Installation](#installation) | ||
- [Communication](#communication) | ||
- [Contributing](#contributing) | ||
- [Author](#author) | ||
- [License](#license) | ||
|
||
## Usage | ||
|
||
1. The `ErrorHandlerMiddleware` is a middleware function designed to handle panics and errors that may occur during the execution of an HTTP handler. | ||
|
||
Here's an example of how to use it in your code: | ||
|
||
```go | ||
// Create a new HTTP handler and wrap it with the ErrorHandlerMiddleware. | ||
handler := ErrorHandlerMiddleware(yourHandler) | ||
|
||
// Use the wrapped handler for your server. | ||
http.Handle("/your-route", handler) | ||
|
||
// Start your HTTP server. | ||
http.ListenAndServe(":8080", nil) | ||
``` | ||
|
||
2. The `LogHandlerMiddleware` is designed to log HTTP requests made to your web application. It captures various details about the request and logs them to your preferred output, which is especially useful for debugging and monitoring. | ||
|
||
```go | ||
// Create a new HTTP handler and wrap it with the LogHandlerMiddleware. | ||
handler := LogHandlerMiddleware(yourHandler) | ||
|
||
// Use the wrapped handler for your HTTP server. | ||
http.Handle("/your-route", handler) | ||
|
||
// Start your HTTP server. | ||
http.ListenAndServe(":8080", nil) | ||
``` | ||
|
||
## Installation | ||
|
||
``` | ||
go get github.com/space-code/go-middleware | ||
``` | ||
|
||
## Communication | ||
- If you **found a bug**, open an issue. | ||
- If you **have a feature request**, open an issue. | ||
- If you **want to contribute**, submit a pull request. | ||
|
||
## Contributing | ||
|
||
Please feel free to help out with this project! If you see something that could be made better or want a new feature, open up an issue or send a Pull Request! | ||
|
||
## Author | ||
Nikita Vasilev, [email protected] | ||
|
||
## License | ||
go-middlewares is available under the MIT license. See the LICENSE file for more info. |
Oops, something went wrong.