envvar

package
v2.37.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: MIT Imports: 4 Imported by: 2

README

Exposing Environment Variables Middleware

EnvVar middleware for Fiber that can be used to expose environment variables with various options.

Table of Contents

Signatures

func New(config ...Config) fiber.Handler

Examples

First import the middleware from Fiber,

import (
  "github.com/gofiber/fiber/v2"
  "github.com/gofiber/fiber/v2/middleware/envvar"
)

Then create a Fiber app with app := fiber.New().

Note: You need to provide a path to use envvar middleware.

Default Config
app.Use("/expose/envvars", envvar.New())
Custom Config
app.Use("/expose/envvars", envvar.New(envvar.Config{
    ExportVars:  map[string]string{"testKey": "", "testDefaultKey": "testDefaultVal"},
    ExcludeVars: map[string]string{"excludeKey": ""}}
}))
Response

Http response contract:

{
  "vars": {
    "someEnvVariable": "someValue",
    "anotherEnvVariable": "anotherValue",
  }
}

Config

// Config defines the config for middleware.
type Config struct {
    // ExportVars specifies the environment variables that should export
    ExportVars map[string]string
    // ExcludeVars specifies the environment variables that should not export
    ExcludeVars map[string]string
}

Default Config

Config{}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(config ...Config) fiber.Handler

Types

type Config

type Config struct {
	// ExportVars specifies the environment variables that should export
	ExportVars map[string]string
	// ExcludeVars specifies the environment variables that should not export
	ExcludeVars map[string]string
}

Config defines the config for middleware.

type EnvVar

type EnvVar struct {
	Vars map[string]string `json:"vars"`
}

Jump to

Keyboard shortcuts

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