Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Go CI

on:
push:
branches:
- main
pull_request:
branches:
- "**"
permissions:
actions: write
contents: read
id-token: write

jobs:
test:
strategy:
matrix:
go-version: ["1.20", "1.23", "1.24"]
os: [ubuntu-latest]
fail-fast: false

runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Go ${{ matrix.go }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache: true

- name: Verify Go version
run: go version

- name: Install dependencies
run: go mod tidy

- name: Run Tests
run: go test -race -coverprofile="coverage.out" -v ./...

- uses: qltysh/qlty-action/coverage@v1
with:
oidc: true
files: coverage.out
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
# Output of the go coverage tool, specifically when used with LiteIDE
*.out

coverage
vendor
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ Package httpware is a collection of middleware (net/http.Handler wrapper) and tr
- **CorrelationId** gets or creates a `correlation_id` and adds it to the `http.request` Context and in the `http.response` header (in order to propagate this ID throught all microservices)
- **Metrics** will use a given Recorder to collect `inflight request`(current parrallel request count), `request duration` and `response size`.

| Name | Middleware | Tripperware|
| ------ | :--------: | :--------: |
|**Authentication**|X||
|**AuthenticationForwarder**||X|
|**CorrelationId**|X|X|
|**Metrics**|X|X|
|**Interceptor**|X|X|
|**Skip**|X|X|
|**Enable**|X|X|
|**RateLimiter**|X|X|
| Name | Middleware | Tripperware|
|-----------------------------| :--------: | :--------: |
| **Authentication** |X||
| **AuthenticationForwarder** ||X|
| **CorrelationId** |X|X|
| **Metrics** |X|X|
| **Interceptor** |X|X|
| **Skip** |X|X|
| **Enable** |X|X|
| **RateLimiter** |X|X|
| **RequestListener** |X|X|
| **CurlLogDumper** |X|X|

## Installation

Expand Down
8 changes: 4 additions & 4 deletions auth/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ func TestFromHeader(t *testing.T) {
{
request: &http.Request{Header: http.Header{
"Authorization": []string{"foo"},
},},
}},
expectedCredential: "foo",
},
{
request: &http.Request{Header: http.Header{
"X-Authorization": []string{"foo"},
},},
}},
expectedCredential: "foo",
},
{
request: &http.Request{Header: http.Header{
"Authorization": []string{"foo"},
"Authorization": []string{"foo"},
"X-Authorization": []string{"bar"},
},},
}},
expectedCredential: "foo",
},
}
Expand Down
2 changes: 1 addition & 1 deletion correlation_id/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"unsafe"
)

//https://stackoverflow.com/a/31832326
// https://stackoverflow.com/a/31832326
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
const (
letterIdxBits = 6 // 6 bits to represent a letter index
Expand Down
24 changes: 16 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
module github.com/gol4ng/httpware/v4

go 1.10
go 1.20

require (
github.com/agiledragon/gomonkey/v2 v2.3.1
github.com/felixge/httpsnoop v1.0.3
github.com/felixge/httpsnoop v1.0.4
github.com/prometheus/client_golang v1.14.0
github.com/stretchr/testify v1.8.2
github.com/stretchr/testify v1.10.0
)

require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/prometheus/common v0.41.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
golang.org/x/sys v0.6.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading