Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Aug 7, 2023
1 parent c909637 commit d708668
Show file tree
Hide file tree
Showing 14 changed files with 206 additions and 111 deletions.
34 changes: 19 additions & 15 deletions contrib_versioned_docs/version-otelfiber_v1.x.x/casbin/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
id: casbin
title: Casbin
---

# Casbin

![Release](https://img.shields.io/github/v/tag/gofiber/contrib?filter=casbin*)
[![Discord](https://img.shields.io/discord/704680098577514527?style=flat&label=%F0%9F%92%AC%20discord&color=00ACD7)](https://gofiber.io/discord)
![Test](https://github.com/gofiber/contrib/workflows/Tests/badge.svg)
Expand All @@ -11,7 +12,9 @@ title: Casbin

Casbin middleware for Fiber.

### Install
**Note: Requires Go 1.18 and above**

## Install
```
go get -u github.com/gofiber/fiber/v2
go get -u github.com/gofiber/contrib/casbin
Expand All @@ -21,26 +24,27 @@ choose an adapter from [here](https://casbin.org/docs/en/adapters)
go get -u github.com/casbin/xorm-adapter
```

### Signature
## Signature
```go
casbin.New(config ...casbin.Config) *casbin.Middleware
```

### Config
| Property | Type | Description | Default |
| :--- | :--- | :--- | :--- |
| ModelFilePath | `string` | Model file path | `"./model.conf"` |
| PolicyAdapter | `persist.Adapter` | Database adapter for policies | `./policy.csv` |
| Enforcer | `*casbin.Enforcer` | Custom casbin enforcer | `Middleware generated enforcer using ModelFilePath & PolicyAdapter` |
| Lookup | `func(*fiber.Ctx) string` | Look up for current subject | `""` |
| Unauthorized | `func(*fiber.Ctx) error` | Response body for unauthorized responses | `Unauthorized` |
| Forbidden | `func(*fiber.Ctx) error` | Response body for forbidden responses | `Forbidden` |
## Config

| Property | Type | Description | Default |
|:--------------|:--------------------------|:-----------------------------------------|:--------------------------------------------------------------------|
| ModelFilePath | `string` | Model file path | `"./model.conf"` |
| PolicyAdapter | `persist.Adapter` | Database adapter for policies | `./policy.csv` |
| Enforcer | `*casbin.Enforcer` | Custom casbin enforcer | `Middleware generated enforcer using ModelFilePath & PolicyAdapter` |
| Lookup | `func(*fiber.Ctx) string` | Look up for current subject | `""` |
| Unauthorized | `func(*fiber.Ctx) error` | Response body for unauthorized responses | `Unauthorized` |
| Forbidden | `func(*fiber.Ctx) error` | Response body for forbidden responses | `Forbidden` |

### Examples
- [Gorm Adapter](https://github.com/svcg/-fiber_casbin_demo)
- [File Adapter](https://github.com/gofiber/contrib/casbin/tree/master/example)

### CustomPermission
## CustomPermission

```go
package main
Expand Down Expand Up @@ -81,7 +85,7 @@ func main() {
}
```

### RoutePermission
## RoutePermission

```go
package main
Expand Down Expand Up @@ -116,7 +120,7 @@ func main() {
}
```

### RoleAuthorization
## RoleAuthorization

```go
package main
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
id: fiberi18n
title: Fiberi18n
---

# Fiberi18n

![Release](https://img.shields.io/github/v/tag/gofiber/contrib?filter=fiberi18n*)
[![Discord](https://img.shields.io/discord/704680098577514527?style=flat&label=%F0%9F%92%AC%20discord&color=00ACD7)](https://gofiber.io/discord)
![Test](https://github.com/gofiber/contrib/workflows/Tests/badge.svg)
Expand All @@ -11,7 +12,9 @@ title: Fiberi18n

[go-i18n](https://github.com/nicksnyder/go-i18n) support for Fiber.

### Install
**Note: Requires Go 1.18 and above**

## Install

This middleware supports Fiber v2.

Expand All @@ -20,13 +23,13 @@ go get -u github.com/gofiber/fiber/v2
go get -u github.com/gofiber/contrib/fiberi18n
```

### Signature
## Signature

```
fiberi18n.New(config ...*Config) fiber.Handler
fiberi18n.New(config ...*fiberi18n.Config) fiber.Handler
```

### Config
## Config

| Property | Type | Description | Default |
| ---------------- | ------------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
Expand All @@ -39,7 +42,7 @@ fiberi18n.New(config ...*Config) fiber.Handler
| UnmarshalFunc | `i18n.UnmarshalFunc` | The function used for decoding template files. | `yaml.Unmarshal` |
| LangHandler | `func(ctx *fiber.Ctx, defaultLang string) string` | Used to get the kind of language handled by *fiber.Ctx and defaultLang. | Retrieved from the request header `Accept-Language` or query parameter `lang`. |

### Example
## Example

```go
package main
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
id: fibernewrelic
title: Fibernewrelic
---

# Fibernewrelic

![Release](https://img.shields.io/github/v/tag/gofiber/contrib?filter=fibernewrelic*)
[![Discord](https://img.shields.io/discord/704680098577514527?style=flat&label=%F0%9F%92%AC%20discord&color=00ACD7)](https://gofiber.io/discord)
![Test](https://github.com/gofiber/contrib/workflows/Tests/badge.svg)
Expand All @@ -11,20 +12,22 @@ title: Fibernewrelic

[NewRelic](https://github.com/newrelic/go-agent) support for Fiber.

### Install
**Note: Requires Go 1.18 and above**

## Install

```
go get -u github.com/gofiber/fiber/v2
go get -u github.com/gofiber/contrib/fibernewrelic
```

### Signature
## Signature

```go
fibernewrelic.New(config fibernewrelic.Config) fiber.Handler
```

### Config
## Config

| Property | Type | Description | Default |
|:------------------|:-----------------|:---------------------------------------|:---------------|
Expand All @@ -35,7 +38,7 @@ fibernewrelic.New(config fibernewrelic.Config) fiber.Handler
| Application | `Application` | Existing New Relic App | `nil` |
| ErrorStatusCodeHandler | `func(c *fiber.Ctx, err error) int` | If you want to change newrelic status code, you can use it. | `DefaultErrorStatusCodeHandler` |

### Usage
## Usage

```go
package main
Expand Down Expand Up @@ -64,7 +67,7 @@ func main() {
}
```

### Usage with existing New Relic application
## Usage with existing New Relic application

```go
package main
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
id: fibersentry
title: Fibersentry
---

# Fibersentry

![Release](https://img.shields.io/github/v/tag/gofiber/contrib?filter=fibersentry*)
[![Discord](https://img.shields.io/discord/704680098577514527?style=flat&label=%F0%9F%92%AC%20discord&color=00ACD7)](https://gofiber.io/discord)
![Test](https://github.com/gofiber/contrib/workflows/Tests/badge.svg)
Expand All @@ -11,7 +12,9 @@ title: Fibersentry

[Sentry](https://sentry.io/) support for Fiber.

### Install
**Note: Requires Go 1.18 and above**

## Install

This middleware supports Fiber v2.

Expand All @@ -21,22 +24,21 @@ go get -u github.com/gofiber/contrib/fibersentry
go get -u github.com/getsentry/sentry-go
```

### Signature
## Signature

```
fibersentry.New(config ...Config) fiber.Handler
fibersentry.New(config ...fibersentry.Config) fiber.Handler
```

### Config

| Property | Type | Description | Default |
| :------------- | :------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :------------------------------ |
| Repanic| `bool` | Repanic configures whether Sentry should repanic after recovery. Set to true, if [Recover](https://github.com/gofiber/fiber/tree/master/middleware/recover) middleware is used. | `false` |
| WaitForDelivery| `bool` | WaitForDelivery configures whether you want to block the request before moving forward with the response. If [Recover](https://github.com/gofiber/fiber/tree/master/middleware/recover) middleware is used, it's safe to either skip this option or set it to false. | `false` |
| Timeout | `time.Duration` | Timeout for the event delivery requests. | `time.Second * 2` |
## Config

| Property | Type | Description | Default |
|:----------------|:----------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------|
| Repanic | `bool` | Repanic configures whether Sentry should repanic after recovery. Set to true, if [Recover](https://github.com/gofiber/fiber/tree/master/middleware/recover) middleware is used. | `false` |
| WaitForDelivery | `bool` | WaitForDelivery configures whether you want to block the request before moving forward with the response. If [Recover](https://github.com/gofiber/fiber/tree/master/middleware/recover) middleware is used, it's safe to either skip this option or set it to false. | `false` |
| Timeout | `time.Duration` | Timeout for the event delivery requests. | `time.Second * 2` |

### Usage
## Usage

`fibersentry` attaches an instance of `*sentry.Hub` (https://godoc.org/github.com/getsentry/sentry-go#Hub) to the request's context, which makes it available throughout the rest of the request's lifetime.
You can access it by using the `fibersentry.GetHubFromContext()` method on the context itself in any of your proceeding middleware and routes.
Expand Down Expand Up @@ -106,7 +108,7 @@ func main() {
}
```

### Accessing Context in `BeforeSend` callback
## Accessing Context in `BeforeSend` callback

```go
sentry.Init(sentry.ClientOptions{
Expand Down
17 changes: 11 additions & 6 deletions contrib_versioned_docs/version-otelfiber_v1.x.x/fiberzap/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
id: fiberzap
title: Fiberzap
---

# Fiberzap

![Release](https://img.shields.io/github/v/tag/gofiber/contrib?filter=fiberzap*)
[![Discord](https://img.shields.io/discord/704680098577514527?style=flat&label=%F0%9F%92%AC%20discord&color=00ACD7)](https://gofiber.io/discord)
![Test](https://github.com/gofiber/contrib/workflows/Tests/badge.svg)
Expand All @@ -11,20 +12,23 @@ title: Fiberzap

[Zap](https://github.com/uber-go/zap) logging support for Fiber.

**Note: Requires Go 1.19 and above**


## Install

This middleware supports Fiber v2.

```
go get -u github.com/gofiber/fiber/v2
go get -u github.com/gofiber/contrib/fiberzap
go get -u github.com/gofiber/contrib/fiberzap/v2
go get -u go.uber.org/zap
```

### Signature

```go
fiberzap.New(config ...Config) fiber.Handler
fiberzap.New(config ...fiberzap.Config) fiber.Handler
```

### Config
Expand All @@ -38,6 +42,7 @@ fiberzap.New(config ...Config) fiber.Handler
| Levels | `[]zapcore.Level` | Custom response levels. | `[]zapcore.Level{zapcore.ErrorLevel, zapcore.WarnLevel, zapcore.InfoLevel}` |
| SkipURIs | `[]string` | Skip logging these URI. | `[]string{}` |
| GetResBody | func(c *fiber.Ctx) []byte | Define a function to get response body when return non-nil.<br />eg: When use compress middleware, resBody is unreadable. you can set GetResBody func to get readable resBody. | `nil` |

### Example
```go
package main
Expand All @@ -46,7 +51,7 @@ import (
"log"

"github.com/gofiber/fiber/v2"
"github.com/gofiber/contrib/fiberzap"
"github.com/gofiber/contrib/fiberzap/v2"
"go.uber.org/zap"
)

Expand All @@ -71,7 +76,7 @@ func main() {
### Signature

```go
fiberzap.NewLogger(config ...LoggerConfig) *LoggerConfig
fiberzap.NewLogger(config ...fiberzap.LoggerConfig) *fiberzap.LoggerConfig
```

### LoggerConfig
Expand All @@ -91,7 +96,7 @@ package main

import (
"context"
"github.com/gofiber/contrib/fiberzap"
"github.com/gofiber/contrib/fiberzap/v2"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/log"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
id: fiberzerolog
title: Fiberzerolog
---

# Fiberzerolog

![Release](https://img.shields.io/github/v/tag/gofiber/contrib?filter=fiberzerolog*)
[![Discord](https://img.shields.io/discord/704680098577514527?style=flat&label=%F0%9F%92%AC%20discord&color=00ACD7)](https://gofiber.io/discord)
![Test](https://github.com/gofiber/contrib/workflows/Tests/badge.svg)
Expand All @@ -11,6 +12,8 @@ title: Fiberzerolog

[Zerolog](https://zerolog.io/) logging support for Fiber.

**Note: Requires Go 1.18 and above**

## Install

This middleware supports Fiber v2.
Expand All @@ -24,7 +27,7 @@ go get -u github.com/rs/zerolog/log
## Signature

```go
fiberzerolog.New(config ...Config) fiber.Handler
fiberzerolog.New(config ...fiberzerolog.Config) fiber.Handler
```

## Config
Expand Down
Loading

0 comments on commit d708668

Please sign in to comment.