config

package
v0.0.0-...-b14b177 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package config contains the configuration of the application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Logging is the logging configuration.
	Logging struct {
		// LogLevel is the log level to use.
		Level string `envconfig:"LOG_LEVEL" default:"debug"`
		// LogFormat is the log format to use.
		Format string `envconfig:"LOG_FORMAT" default:"console"`
	}
	// Server is the http server configuration.
	Server struct {
		// GinMode is the mode to run the server in.
		GinMode string `envconfig:"GIN_MODE" default:"release"`
		// Port is the port to listen on.
		Port int `envconfig:"SERVER_PORT" default:"8080"`
		// Meddlewares is the configuration for the middlewares.
		Middlewares struct {
			// Ratelimiter is the configuration for the ratelimiter middleware.
			Ratelimiter struct {
				// Rate is the rate at which requests are allowed.
				Rate ratelimiter.Rate `envconfig:"RATELIMITER_RATE" default:"second"`
				// Limit is the maximum number of requests allowed.
				Limit uint `envconfig:"RATELIMITER_LIMIT" default:"5"`
				// Key is the key to use for the ratelimiter.
				Key ratelimiter.Key `envconfig:"RATELIMITER_KEY" default:"client_ip"`
			}
			// Proofer is the configuration for the proofer middleware.
			Proofer struct {
				// ChallengeDifficulty is the difficulty of the proof of work challenge.
				ChallengeDifficulty int `envconfig:"CHALLENGE_DIFFICULTY" default:"20"`
				// SaltLength is the length of the salt.
				SaltLength int `envconfig:"SALT_LENGTH" default:"8"`
			}
		}
	}
}

Config is the main configuration of the application. It is populated from environment variables and defaults.

func NewConfig

func NewConfig() (*Config, error)

NewConfig returns a new Config instance, populated with environment variables and defaults.

Jump to

Keyboard shortcuts

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