From 640582e66397af35ce37e752c5142fce1b62e806 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 2 Sep 2024 08:01:03 +0000 Subject: [PATCH] Sync docs for release https://github.com/gofiber/contrib/releases/tag/socketio/v1.1.3 --- .../otelfiber/README.md | 23 ++++++++++--------- .../websocket/README.md | 10 +++++++- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/contrib_versioned_docs/version-socketio_v1.x.x/otelfiber/README.md b/contrib_versioned_docs/version-socketio_v1.x.x/otelfiber/README.md index 5d3a215b4b4..200a05c5649 100644 --- a/contrib_versioned_docs/version-socketio_v1.x.x/otelfiber/README.md +++ b/contrib_versioned_docs/version-socketio_v1.x.x/otelfiber/README.md @@ -34,17 +34,18 @@ otelfiber.Middleware(opts ...otelfiber.Option) fiber.Handler You can configure the middleware using functional parameters -| Function | Argument Type | Description | Default | -| :------------------ | :-------------------------------- | :--------------------------------------------------------------------------------- | :-------------------------------------------------------------------- | -| `WithNext` | `func(*fiber.Ctx) bool` | Define a function to skip this middleware when returned true .| nil | -| `WithTracerProvider` | `oteltrace.TracerProvider` | Specifies a tracer provider to use for creating a tracer. | nil - the global tracer provider is used | -| `WithMeterProvider` | `otelmetric.MeterProvider` | Specifies a meter provider to use for reporting. | nil - the global meter provider is used | -| `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`) | -| `WithPropagators` | `propagation.TextMapPropagator` | Specifies propagators to use for extracting information from the HTTP requests. | If none are specified, global ones will be used | -| `WithServerName` | `string` | Specifies the value to use when setting the `http.server_name` attribute on metrics/spans. | - | -| `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 | -| `WithCustomAttributes` | `func(*fiber.Ctx) []attribute.KeyValue` | Define a function to add custom attributes to the span. | nil | -| `WithCollectClientIP` | `bool` | Specifies whether to collect the client's IP address from the request. | true | +| Function | Argument Type | Description | Default | +| :------------------------ | :-------------------------------- | :--------------------------------------------------------------------------------- | :-------------------------------------------------------------------- | +| `WithNext` | `func(*fiber.Ctx) bool` | Define a function to skip this middleware when returned true .| nil | +| `WithTracerProvider` | `oteltrace.TracerProvider` | Specifies a tracer provider to use for creating a tracer. | nil - the global tracer provider is used | +| `WithMeterProvider` | `otelmetric.MeterProvider` | Specifies a meter provider to use for reporting. | nil - the global meter provider is used | +| `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`) | +| `WithPropagators` | `propagation.TextMapPropagator` | Specifies propagators to use for extracting information from the HTTP requests. | If none are specified, global ones will be used | +| `WithServerName` | `string` | Specifies the value to use when setting the `http.server_name` attribute on metrics/spans. | - | +| `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 | +| `WithCustomAttributes` | `func(*fiber.Ctx) []attribute.KeyValue` | Define a function to add custom attributes to the span. | nil | +| `WithCustomMetricAttributes` | `func(*fiber.Ctx) []attribute.KeyValue` | Define a function to add custom attributes to the metrics. | nil | +| `WithCollectClientIP` | `bool` | Specifies whether to collect the client's IP address from the request. | true | ## Usage diff --git a/contrib_versioned_docs/version-socketio_v1.x.x/websocket/README.md b/contrib_versioned_docs/version-socketio_v1.x.x/websocket/README.md index 3c7214ab0ba..fef6219e258 100644 --- a/contrib_versioned_docs/version-socketio_v1.x.x/websocket/README.md +++ b/contrib_versioned_docs/version-socketio_v1.x.x/websocket/README.md @@ -142,4 +142,12 @@ cfg := Config{ app.Get("/ws/:id", websocket.New(func(c *websocket.Conn) {}, cfg)) -``` \ No newline at end of file +``` + +## Note for WebSocket subprotocols + +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) . + +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()`. + +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.