bmw

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

README

BunRouter Middleware (BMW)

This library provides a set of useful middlewares for the BunRouter package in Go.

Installation

To install the library, run the following command:

go get github.com/atridadl/bmw

Usage

Here's an example of how to use the middlewares in this library:

package main

import (
    bmw "github.com/atridadl/bmw"
    "github.com/uptrace/bunrouter"
)

func main() {
    router := bunrouter.New()
    router.Use(bmw.RateLimit())
    router.Use(bmw.RequestID())
    router.Use(bmw.Secure())
    // ...
}

Middlewares

RateLimit

The RateLimit middleware helps to limit the rate of incoming requests.

RequestID

The RequestID middleware assigns a unique ID to each incoming request.

Secure

The Secure middleware adds security-related headers to responses.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HeaderXRequestID = "X-Request-ID"
)

Functions

func GetRequestID

func GetRequestID(ctx context.Context) string

func NewRateLimiter

func NewRateLimiter(rps int) *rateLimiter

func SecureHeaders

func SecureHeaders(next bunrouter.HandlerFunc) bunrouter.HandlerFunc

Types

This section is empty.

Jump to

Keyboard shortcuts

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