Skip to content

Commit dc3aa05

Browse files
1 parent cd09c9b commit dc3aa05

File tree

7 files changed

+114
-15
lines changed

7 files changed

+114
-15
lines changed

contrib_versioned_docs/version-paseto_v1.x.x/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Repository for third party middlewares with dependencies.
2929
* [JWT](./jwt/README.md) <a href="https://github.com/gofiber/contrib/actions?query=workflow%3A%22Test+jwt%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/contrib/test-jwt.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
3030
* [Loadshed](./loadshed/README.md) <a href="https://github.com/gofiber/contrib/actions?query=workflow%3A%22Test+loadshed%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/contrib/test-loadshed.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
3131
* [NewRelic](./fibernewrelic/README.md) <a href="https://github.com/gofiber/contrib/actions?query=workflow%3A%22Test+fibernewrelic%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/contrib/test-fibernewrelic.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
32+
* [Monitor](./monitor/README.md) <a href="https://github.com/gofiber/contrib/actions?query=workflow%3A%22Test+Monitor%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/contrib/test-monitor.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
3233
* [Open Policy Agent](./opafiber/README.md) <a href="https://github.com/gofiber/contrib/actions?query=workflow%3A%22Test+opafiber%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/contrib/test-opafiber.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
3334
* [Otelfiber (OpenTelemetry)](./otelfiber/README.md) <a href="https://github.com/gofiber/contrib/actions?query=workflow%3A%22Test+otelfiber%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/contrib/test-otelfiber.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
3435
* [Paseto](./paseto/README.md) <a href="https://github.com/gofiber/contrib/actions?query=workflow%3A%22Test+paseto%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/contrib/test-paseto.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>

contrib_versioned_docs/version-paseto_v1.x.x/fiberzap/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import (
5959
func main() {
6060
app := fiber.New()
6161
logger, _ := zap.NewProduction()
62+
defer logger.Sync()
6263

6364
app.Use(fiberzap.New(fiberzap.Config{
6465
Logger: logger,
@@ -103,9 +104,12 @@ import (
103104

104105
func main() {
105106
app := fiber.New()
106-
log.SetLogger(fiberzap.NewLogger(fiberzap.LoggerConfig{
107+
logger := fiberzap.NewLogger(fiberzap.LoggerConfig{
107108
ExtraKeys: []string{"request_id"},
108-
}))
109+
})
110+
log.SetLogger(logger)
111+
defer logger.Sync()
112+
109113
app.Use(func(c *fiber.Ctx) error {
110114
ctx := context.WithValue(c.UserContext(), "request_id", "123")
111115
c.SetUserContext(ctx)
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
id: monitor
3+
---
4+
5+
# Monitor
6+
7+
![Release](https://img.shields.io/github/v/tag/gofiber/contrib?filter=monitor*)
8+
![Discord](https://img.shields.io/discord/704680098577514527?style=flat&label=%F0%9F%92%AC%20discord&color=00ACD7)
9+
![Test](https://github.com/gofiber/contrib/workflows/Tests/badge.svg)
10+
![Security](https://github.com/gofiber/contrib/workflows/Security/badge.svg)
11+
![Linter](https://github.com/gofiber/contrib/workflows/Linter/badge.svg)
12+
13+
Monitor middleware for [Fiber](https://github.com/gofiber/fiber) that reports server metrics, inspired by [express-status-monitor](https://github.com/RafalWilinski/express-status-monitor)
14+
15+
![](https://i.imgur.com/nHAtBpJ.gif)
16+
17+
## Install
18+
19+
This middleware supports Fiber v3.
20+
21+
```
22+
go get -u github.com/gofiber/fiber/v3
23+
go get -u github.com/gofiber/contrib/monitor
24+
```
25+
26+
### Signature
27+
28+
```go
29+
monitor.New(config ...monitor.Config) fiber.Handler
30+
```
31+
32+
### Config
33+
34+
| Property | Type | Description | Default |
35+
| :--------- | :------------------------ | :----------------------------------------------------------------------------------- | :-------------------------------------------------------------------------- |
36+
| Title | `string` | Metrics page title. | `Fiber Monitor` |
37+
| Refresh | `time.Duration` | Refresh period. | `3 seconds` |
38+
| APIOnly | `bool` | Whether the service should expose only the montioring API. | `false` |
39+
| Next | `func(c *fiber.Ctx) bool` | Define a function to add custom fields. | `nil` |
40+
| CustomHead | `string` | Custom HTML code to Head Section(Before End). | `empty` |
41+
| FontURL | `string` | FontURL for specilt font resource path or URL. also you can use relative path. | `https://fonts.googleapis.com/css2?family=Roboto:wght@400;900&display=swap` |
42+
| ChartJsURL | `string` | ChartJsURL for specilt chartjs library, path or URL, also you can use relative path. | `https://cdn.jsdelivr.net/npm/[email protected]/dist/Chart.bundle.min.js` |
43+
44+
### Example
45+
46+
```go
47+
package main
48+
49+
import (
50+
"log"
51+
52+
"github.com/gofiber/fiber/v3"
53+
"github.com/gofiber/contrib/monitor"
54+
)
55+
56+
func main() {
57+
app := fiber.New()
58+
59+
// Initialize default config (Assign the middleware to /metrics)
60+
app.Get("/metrics", monitor.New())
61+
62+
// Or extend your config for customization
63+
// Assign the middleware to /metrics
64+
// and change the Title to `MyService Metrics Page`
65+
app.Get("/metrics", monitor.New(monitor.Config{Title: "MyService Metrics Page"}))
66+
67+
log.Fatal(app.Listen(":3000"))
68+
}
69+
```
70+
71+
72+
## Default Config
73+
74+
```go
75+
var ConfigDefault = Config{
76+
Title: defaultTitle,
77+
Refresh: defaultRefresh,
78+
FontURL: defaultFontURL,
79+
ChartJsURL: defaultChartJSURL,
80+
CustomHead: defaultCustomHead,
81+
APIOnly: false,
82+
Next: nil,
83+
}
84+
```

contrib_versioned_docs/version-paseto_v1.x.x/otelfiber/README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,18 @@ otelfiber.Middleware(opts ...otelfiber.Option) fiber.Handler
3434
You can configure the middleware using functional parameters
3535

3636

37-
| Function | Argument Type | Description | Default |
38-
| :------------------ | :-------------------------------- | :--------------------------------------------------------------------------------- | :-------------------------------------------------------------------- |
39-
| `WithNext` | `func(*fiber.Ctx) bool` | Define a function to skip this middleware when returned true .| nil |
40-
| `WithTracerProvider` | `oteltrace.TracerProvider` | Specifies a tracer provider to use for creating a tracer. | nil - the global tracer provider is used |
41-
| `WithMeterProvider` | `otelmetric.MeterProvider` | Specifies a meter provider to use for reporting. | nil - the global meter provider is used |
42-
| `WithPort` | `int` | Specifies the value to use when setting the `net.host.port` attribute on metrics/spans. | Defaults to (`80` for `http`, `443` for `https`) |
43-
| `WithPropagators` | `propagation.TextMapPropagator` | Specifies propagators to use for extracting information from the HTTP requests. | If none are specified, global ones will be used |
44-
| `WithServerName` | `string` | Specifies the value to use when setting the `http.server_name` attribute on metrics/spans. | - |
45-
| `WithSpanNameFormatter` | `func(*fiber.Ctx) string` | Takes a function that will be called on every request and the returned string will become the span Name. | Default formatter returns the route pathRaw |
46-
| `WithCustomAttributes` | `func(*fiber.Ctx) []attribute.KeyValue` | Define a function to add custom attributes to the span. | nil |
47-
| `WithCollectClientIP` | `bool` | Specifies whether to collect the client's IP address from the request. | true |
37+
| Function | Argument Type | Description | Default |
38+
| :------------------------ | :-------------------------------- | :--------------------------------------------------------------------------------- | :-------------------------------------------------------------------- |
39+
| `WithNext` | `func(*fiber.Ctx) bool` | Define a function to skip this middleware when returned true .| nil |
40+
| `WithTracerProvider` | `oteltrace.TracerProvider` | Specifies a tracer provider to use for creating a tracer. | nil - the global tracer provider is used |
41+
| `WithMeterProvider` | `otelmetric.MeterProvider` | Specifies a meter provider to use for reporting. | nil - the global meter provider is used |
42+
| `WithPort` | `int` | Specifies the value to use when setting the `net.host.port` attribute on metrics/spans. | Defaults to (`80` for `http`, `443` for `https`) |
43+
| `WithPropagators` | `propagation.TextMapPropagator` | Specifies propagators to use for extracting information from the HTTP requests. | If none are specified, global ones will be used |
44+
| `WithServerName` | `string` | Specifies the value to use when setting the `http.server_name` attribute on metrics/spans. | - |
45+
| `WithSpanNameFormatter` | `func(*fiber.Ctx) string` | Takes a function that will be called on every request and the returned string will become the span Name. | Default formatter returns the route pathRaw |
46+
| `WithCustomAttributes` | `func(*fiber.Ctx) []attribute.KeyValue` | Define a function to add custom attributes to the span. | nil |
47+
| `WithCustomMetricAttributes` | `func(*fiber.Ctx) []attribute.KeyValue` | Define a function to add custom attributes to the metrics. | nil |
48+
| `WithCollectClientIP` | `bool` | Specifies whether to collect the client's IP address from the request. | true |
4849

4950
## Usage
5051

contrib_versioned_docs/version-paseto_v1.x.x/socketio/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
id: socketio
23
---
34

contrib_versioned_docs/version-paseto_v1.x.x/websocket/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,12 @@ cfg := Config{
142142
app.Get("/ws/:id", websocket.New(func(c *websocket.Conn) {}, cfg))
143143

144144

145-
```
145+
```
146+
147+
## Note for WebSocket subprotocols
148+
149+
The config `Subprotocols` only helps you negotiate subprotocols and sets a `Sec-Websocket-Protocol` header if it has a suitable subprotocol. For more about negotiates process, check the comment for `Subprotocols` in [fasthttp.Upgrader](https://pkg.go.dev/github.com/fasthttp/websocket#Upgrader) .
150+
151+
All connections will be sent to the handler function no matter whether the subprotocol negotiation is successful or not. You can get the selected subprotocol from `conn.Subprotocol()`.
152+
153+
If a connection includes the `Sec-Websocket-Protocol` header in the request but the protocol negotiation fails, the browser will immediately disconnect the connection after receiving the upgrade response.

contrib_versioned_sidebars/version-paseto_v1.x.x-sidebars.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"tutorialSidebar": [
2+
"left_sidebar": [
33
{
44
"type": "autogenerated",
55
"dirName": "."

0 commit comments

Comments
 (0)