Skip to content

Commit

Permalink
✨ add middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
zcubbs committed Oct 15, 2023
1 parent 7f5ef5e commit 12eb883
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 16 deletions.
6 changes: 1 addition & 5 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@ linters-settings:
gosec:
# To specify a set of rules to explicitly exclude.
# Available rules: https://github.com/securego/gosec#available-rules
excludes:
- G204 # Audit use of command execution
- G304 # File path provided as taint input
- G303 # Creating tempfile using a predictable path
- G306 # Poor file permissions used when writing to a new file
excludes: []
2 changes: 1 addition & 1 deletion .gosec.config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"global": {
"exclude": "G204,G302,G303,G304,G306,G404,G402"
"exclude": ""
}
}
56 changes: 46 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,49 @@
# Go K8s
# Fiber Middleware for charmbracelet/log

A K8s collection of Go Packages.
A GoFiber middleware for Charmlog logger.

[![tag](https://img.shields.io/github/tag/zcubbs/go-k8s)](https://github.com/zcubbs/go-k8s/releases)
- Fiber: https://github.com/gofiber/fiber
- charmbracelet/log: https://github.com/charmbracelet/log

[![tag](https://img.shields.io/github/tag/zcubbs/charmlogfiber)](https://github.com/zcubbs/charmlogfiber/releases)
![Go Version](https://img.shields.io/badge/Go-%3E%3D%201.21-%23007d9c)
[![GoDoc](https://godoc.org/github.com/zcubbs/go-k8s?status.svg)](https://pkg.go.dev/github.com/zcubbs/go-k8s)
[![Lint](https://github.com/zcubbs/go-k8s/actions/workflows/lint.yaml/badge.svg)](https://github.com/zcubbs/go-k8s/actions/workflows/lint.yaml)
[![Scan](https://github.com/zcubbs/go-k8s/actions/workflows/scan.yaml/badge.svg?branch=main)](https://github.com/zcubbs/go-k8s/actions/workflows/scan.yaml)
![Build Status](https://github.com/zcubbs/go-k8s/actions/workflows/test.yaml/badge.svg)
[![Go Report Card](https://goreportcard.com/badge/github.com/zcubbs/go-k8s)](https://goreportcard.com/report/github.com/zcubbs/go-k8s)
[![Contributors](https://img.shields.io/github/contributors/zcubbs/go-k8s)](https://github.com/zcubbs/go-k8s/graphs/contributors)
[![License](https://img.shields.io/github/license/zcubbs/go-k8s.svg)](./LICENSE)
[![GoDoc](https://godoc.org/github.com/zcubbs/charmlogfiber?status.svg)](https://pkg.go.dev/github.com/zcubbs/charmlogfiber)
[![Lint](https://github.com/zcubbs/charmlogfiber/actions/workflows/lint.yaml/badge.svg)](https://github.com/zcubbs/charmlogfiber/actions/workflows/lint.yaml)
[![Scan](https://github.com/zcubbs/charmlogfiber/actions/workflows/scan.yaml/badge.svg?branch=main)](https://github.com/zcubbs/charmlogfiber/actions/workflows/scan.yaml)
![Build Status](https://github.com/zcubbs/charmlogfiber/actions/workflows/test.yaml/badge.svg)
[![Go Report Card](https://goreportcard.com/badge/github.com/zcubbs/charmlogfiber)](https://goreportcard.com/report/github.com/zcubbs/charmlogfiber)
[![Contributors](https://img.shields.io/github/contributors/zcubbs/charmlogfiber)](https://github.com/zcubbs/charmlogfiber/graphs/contributors)
[![License](https://img.shields.io/github/license/zcubbs/charmlogfiber.svg)](./LICENSE)

## Usage

```go
package main

import (
"github.com/gofiber/fiber/v2"
"github.com/charmbracelet/log"
"github.com/zcubbs/charmlogfiber"
"os"
)

func main() {
app := fiber.New()

logger := log.New(os.Stderr)
// Create a new logger
fiberLogger := charmlogfiber.New(logger)

// Use the logger in the Fiber app
app.Use(fiberLogger)

app.Get("/", func(c *fiber.Ctx) error {
// Log a message
logger.Info("Hello, World!")

return c.SendString("Hello, World!")
})

app.Listen(":3000")
}
```
25 changes: 25 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
module charmlogfiber

go 1.21

require (
github.com/charmbracelet/log v0.2.5
github.com/gofiber/fiber/v2 v2.49.2
github.com/google/uuid v1.3.1
)

require (
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/lipgloss v0.8.0 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.49.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
golang.org/x/sys v0.12.0 // indirect
)
1 change: 1 addition & 0 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"

"github.com/charmbracelet/log"
"github.com/gofiber/fiber/v2"
"github.com/google/uuid"
)

Expand Down

0 comments on commit 12eb883

Please sign in to comment.