olusofiber

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 4 Imported by: 0

README

olusofiber

Oluso error monitoring middleware for Fiber.

Installation

go get github.com/olusodotdev/oluso-go/fiber

Usage

package main

import (
	"context"
	"log"
	"time"

	"github.com/gofiber/fiber/v2"
	"github.com/olusodotdev/oluso-go/fiber"
	"github.com/olusodotdev/oluso-go"
)

func main() {
	client, err := oluso.New(oluso.Options{APIKey: "your-api-key"})
	if err != nil {
		log.Fatal(err)
	}
	defer func() {
		ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
		defer cancel()
		client.Flush(ctx)
	}()

	app := fiber.New()
	app.Use(olusofiber.Middleware(client))

	app.Get("/", func(c *fiber.Ctx) error {
		panic("something went wrong") // captured and reported automatically
	})

	log.Fatal(app.Listen(":8080"))
}

Middleware scopes breadcrumbs to each request (accessible via c.UserContext()), auto-reports panics and 5xx responses — including handlers that return fiber.NewError(500, ...) rather than writing directly — and recovers from panics so one bad request doesn't take down the server.

Fiber is built on fasthttp rather than net/http, so this adapter builds request context (URL, method, headers, query, IP) directly from fiber.Ctx instead of a *http.Request. Everything else is identical to the other Oluso Go adapters.

See the root README for breadcrumbs, user context, manual reporting, and configuration.

License

MIT

Documentation

Overview

Package olusofiber provides Oluso error monitoring middleware for Fiber.

Fiber is built on fasthttp rather than net/http, so unlike the Gin and Echo adapters this one can't reuse Client.CaptureHTTPError (which takes a *http.Request) — it builds a RequestContext directly from fiber.Ctx and reports it via Client.CaptureRequestError instead.

Named olusofiber rather than fiber so it doesn't collide with (or force aliasing of) the github.com/gofiber/fiber/v2 import in consuming code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(client *oluso.Client) fiber.Handler

Middleware wraps Fiber's request handling with Oluso error monitoring: it scopes breadcrumbs to the request, auto-reports panics and 5xx responses (including handlers that return a *fiber.Error instead of writing directly), and recovers from panics so one bad request doesn't take down the server.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL