Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ feat: Add support for CookieConfig in Redirect #3076

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a19709a
Updates to Redirect configuration and documentation
gaby Jul 16, 2024
acedda3
Update Redirect Benchmarks
gaby Jul 16, 2024
6d41e97
v3: Improve performance of Adaptor Middleware (#3078)
gaby Jul 18, 2024
7156af6
✨ feat: Add Startup Probe to Healthcheck Middleware (#3069)
kirankumar-grootan Jul 18, 2024
dfb1d2a
:sparkles: feat: Add support for RebuildTree (#3074)
luk3skyw4lker Jul 18, 2024
3a4d7b9
add manual dependabot trigger workflow
ReneWerner87 Jul 22, 2024
2505aef
test(ctx_test): Fix race condition (#3081)
sixcolors Jul 22, 2024
30c5a69
v3: Refactor Benchmark Results Workflow (#3082)
gaby Jul 22, 2024
d0583da
add manual dependabot trigger workflow
ReneWerner87 Jul 22, 2024
abf1898
Update benchmark.yml
ReneWerner87 Jul 22, 2024
2788a53
🐛 bug: Use Content-Length for bytesReceived and bytesSent tags in Log…
gaby Jul 23, 2024
25c9fa2
🐛 [Bug]: cache middleware: runtime error: index out of range [0] with…
brunodmartins Jul 23, 2024
0f046cc
v3: Use Named Fields Instead of Positional and Align Structures to Re…
gaby Jul 23, 2024
d7d9159
v3: Improve performance of helper functions (#3086)
gaby Jul 23, 2024
c902190
:sparkles: feat: Add Max Func to Limiter Middleware (#3070)
luk3skyw4lker Jul 23, 2024
401d96d
build(deps): bump actions/checkout from 3 to 4 (#3083)
dependabot[bot] Jul 24, 2024
d186549
Use utils Trim functions instead of the strings/bytes functions (#3087)
ReneWerner87 Jul 24, 2024
7ae39c4
Align structs
gaby Jul 25, 2024
e68de00
Align structs
gaby Jul 25, 2024
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
84 changes: 73 additions & 11 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,23 @@ on:
paths-ignore:
- "**/*.md"

permissions:
# deployments permission to deploy GitHub pages website
deployments: write
# contents permission to update benchmark contents in gh-pages branch
contents: write
# allow posting comments to pull request
pull-requests: write

name: Benchmark
jobs:
Compare:
runs-on: ubuntu-latest
steps:
- name: Fetch Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # to be able to retrieve the last commit in main

- name: Install Go
uses: actions/setup-go@v5
Expand All @@ -26,24 +36,76 @@ jobs:
- name: Run Benchmark
run: set -o pipefail; go test ./... -benchmem -run=^$ -bench . | tee output.txt

- name: Get Previous Benchmark Results
uses: actions/cache@v4
# NOTE: Benchmarks could change with different CPU types
- name: Get GitHub Runner System Information
uses: kenchan0130/[email protected]
id: system-info

- name: Get Main branch SHA
id: get-main-branch-sha
run: |
SHA=$(git rev-parse origin/main)
echo "sha=$SHA" >> $GITHUB_OUTPUT

- name: Get Benchmark Results from main branch
id: cache
uses: actions/cache/restore@v4
with:
path: ./cache
key: ${{ runner.os }}-benchmark
key: ${{ steps.get-main-branch-sha.outputs.sha }}-${{ runner.os }}-${{ steps.system-info.outputs.cpu-model }}-benchmark

- name: Save Benchmark Results
# This will only run if we have Benchmark Results from main branch
- name: Compare PR Benchmark Results with main branch
uses: benchmark-action/[email protected]
if: steps.cache.outputs.cache-hit == 'true'
with:
tool: "go"
tool: 'go'
output-file-path: output.txt
github-token: ${{ secrets.BENCHMARK_TOKEN }}
benchmark-data-dir-path: "benchmarks"
external-data-json-path: ./cache/benchmark-data.json
# Do not save the data (This allows comparing benchmarks)
save-data-file: false
fail-on-alert: true
comment-on-alert: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
# Enable Job Summary for PRs - deactivated because of issues
#summary-always: ${{ github.event_name != 'push' && github.event_name != 'workflow_dispatch' }}
# Comment on the PR if the branch is not a fork
comment-on-alert: ${{ github.event.pull_request.head.repo.fork == false }}
github-token: ${{ secrets.GITHUB_TOKEN }}
summary-always: true
alert-threshold: "150%"

- name: Store Benchmark Results for main branch
uses: benchmark-action/[email protected]
if: ${{ github.ref_name == 'main' }}
with:
tool: 'go'
output-file-path: output.txt
external-data-json-path: ./cache/benchmark-data.json
# Save the data to external file (cache)
save-data-file: true
fail-on-alert: false
github-token: ${{ secrets.GITHUB_TOKEN }}
summary-always: true
alert-threshold: "150%"

- name: Publish Benchmark Results to GitHub Pages
uses: benchmark-action/[email protected]
if: ${{ github.ref_name == 'main' }}
with:
tool: 'go'
output-file-path: output.txt
benchmark-data-dir-path: "benchmarks"
fail-on-alert: false
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-on-alert: true
summary-always: true
# Save the data to external file (GitHub Pages)
save-data-file: true
alert-threshold: "150%"
# TODO: reactivate it later -> when v3 is the stable one
#auto-push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
auto-push: false
save-data-file: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}

- name: Update Benchmark Results cache
uses: actions/cache/save@v4
if: ${{ github.ref_name == 'main' }}
with:
path: ./cache
key: ${{ steps.get-main-branch-sha.outputs.sha }}-${{ runner.os }}-${{ steps.system-info.outputs.cpu-model }}-benchmark
46 changes: 46 additions & 0 deletions .github/workflows/manual-dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# https://github.com/dependabot/dependabot-script/blob/main/manual-github-actions.yaml
# https://github.com/dependabot/dependabot-script?tab=readme-ov-file#github-actions-standalone
name: ManualDependabot

on:
workflow_dispatch:
inputs:
package-manager:
description: 'The package manager to use'
required: true
default: 'gomod'
directory:
description: 'The directory to scan'
required: true
default: '/'

permissions:
contents: read

jobs:
dependabot:
permissions:
contents: write # for Git to git push
pull-requests: write # for repo-sync/pull-request to create pull requests
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Checkout dependabot
run: |
cd /tmp/
git clone https://github.com/dependabot/dependabot-script

- name: Build image
run: |
cd /tmp/dependabot-script
docker build -t "dependabot/dependabot-script" -f Dockerfile .

- name: Run dependabot
env:
PACKAGE_MANAGER: ${{ github.event.inputs.package-manager }}
DIRECTORY: ${{ github.event.inputs.directory }}
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
docker run -v $PWD:/src -e PROJECT_PATH=$GITHUB_REPOSITORY -e PACKAGE_MANAGER=$PACKAGE_MANAGER -e DIRECTORY=$DIRECTORY -e GITHUB_ACCESS_TOKEN=$GITHUB_ACCESS_TOKEN -e OPTIONS="$OPTIONS" dependabot/dependabot-script
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ linters-settings:
govet:
enable-all: true
disable:
- fieldalignment
- shadow

grouper:
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ format:

## format: 🎨 Find markdown format issues (Requires markdownlint-cli)
.PHONY: markdown
format:
markdown:
markdownlint-cli2 "**/*.md" "#vendor"

## lint: 🚨 Run lint checks
Expand All @@ -51,3 +51,8 @@ longtest:
.PHONY: tidy
tidy:
go mod tidy -v

## betteralign: 📐 Optimize alignment of fields in structs
.PHONY: betteralign
betteralign:
go run github.com/dkorunic/betteralign/cmd/betteralign@latest -test_files -generated_files -apply ./...
4 changes: 2 additions & 2 deletions addon/retry/exponential_backoff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
func Test_ExponentialBackoff_Retry(t *testing.T) {
t.Parallel()
tests := []struct {
name string
expErr error
expBackoff *ExponentialBackoff
f func() error
expErr error
name string
}{
{
name: "With default values - successful",
Expand Down
38 changes: 19 additions & 19 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,29 +80,16 @@ type ErrorHandler = func(Ctx, error) error

// Error represents an error that occurred while handling a request.
type Error struct {
Code int `json:"code"`
Message string `json:"message"`
Code int `json:"code"`
}

// App denotes the Fiber application.
type App struct {
mutex sync.Mutex
// Route stack divided by HTTP methods
stack [][]*Route
// Route stack divided by HTTP methods and route prefixes
treeStack []map[string][]*Route
// contains the information if the route stack has been changed to build the optimized tree
routesRefreshed bool
// Amount of registered routes
routesCount uint32
// Amount of registered handlers
handlersCount uint32
// Ctx pool
pool sync.Pool
// Fasthttp server
server *fasthttp.Server
// App config
config Config
// Converts string to a byte slice
getBytes func(s string) (b []byte)
// Converts byte slice to a string
Expand All @@ -113,24 +100,37 @@ type App struct {
latestRoute *Route
// newCtxFunc
newCtxFunc func(app *App) CustomCtx
// custom binders
customBinders []CustomBinder
// TLS handler
tlsHandler *TLSHandler
// Mount fields
mountFields *mountFields
// Indicates if the value was explicitly configured
configured Config
// Route stack divided by HTTP methods
stack [][]*Route
// Route stack divided by HTTP methods and route prefixes
treeStack []map[string][]*Route
// custom binders
customBinders []CustomBinder
// customConstraints is a list of external constraints
customConstraints []CustomConstraint
// sendfiles stores configurations for handling ctx.SendFile operations
sendfiles []*sendFileStore
// App config
config Config
// Indicates if the value was explicitly configured
configured Config
// sendfilesMutex is a mutex used for sendfile operations
sendfilesMutex sync.RWMutex
mutex sync.Mutex
// Amount of registered routes
routesCount uint32
// Amount of registered handlers
handlersCount uint32
// contains the information if the route stack has been changed to build the optimized tree
routesRefreshed bool
}

// Config is a struct holding the server settings.
type Config struct {
type Config struct { //nolint:govet // Aligning the struct fields is not necessary. betteralign:ignore
// Enables the "Server: value" HTTP header.
//
// Default: ""
Expand Down
Loading