config

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRetryCount = 3
	DefaultRetryDelay = time.Second * 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cfg

type Cfg func(c *Config)

func WithDatabase

func WithDatabase(driver, dsn string) Cfg

func WithDebug

func WithDebug(debug bool) Cfg

func WithGracePeriod

func WithGracePeriod(gracePeriod int) Cfg

func WithPort

func WithPort(port int) Cfg

type Config

type Config struct {
	Server      Server                 `json:"server" yaml:"server"`
	Database    Database               `json:"database" yaml:"database"`
	JWT         JWT                    `json:"jwt" yaml:"jwt"`
	OAuthConfig map[string]OAuthConfig `json:"oauth" yaml:"oauth"`
	Email       Email                  `json:"email" yaml:"email"`
}

func Current

func Current(cfgs ...Cfg) *Config

func New

func New(cfgs ...Cfg) *Config

type Database

type Database struct {
	Driver string `json:"driver" yaml:"driver" default:"sqlite"`
	DSN    string `json:"dsn" yaml:"dsn" default:"db.sqlite"`

	MaxIdleConn int           `json:"maxIdleConn" yaml:"maxIdleConn" default:"10"`
	MaxOpenConn int           `json:"maxOpenConn" yaml:"maxOpenConn" default:"40"`
	ConnMaxLift time.Duration `json:"connMaxLift" yaml:"connMaxLift" default:"0s"`
	ConnMaxIdle time.Duration `json:"connMaxIdle" yaml:"connMaxIdle" default:"0s"`
}

type Email

type Email struct {
	Host     string `json:"host" yaml:"host" default:"smtp-mail.outlook.com"`
	Port     int    `json:"port" yaml:"port" default:"587"`
	Username string `json:"username" yaml:"username"`
	Alias    string `json:"alias" yaml:"alias"`
	Password string `json:"password" yaml:"password"`
}

type JWT

type JWT struct {
	Secret string        `json:"secret" yaml:"secret" default:"aurora"`
	Issuer string        `json:"issuer" yaml:"issuer" default:"fun.toodo.aurora"`
	Expire time.Duration `json:"expire" yaml:"expire" default:"720h"`
}

type OAuthConfig

type OAuthConfig struct {
	AuthType     string `json:"authType" yaml:"authType"`
	AuthURL      string `json:"authURL" yaml:"authURL"`
	TokenURL     string `json:"tokenURL" yaml:"tokenURL"`
	ClientId     string `json:"clientId" yaml:"clientId"`
	ClientSecret string `json:"clientSecret" yaml:"clientSecret"`
}

type Server

type Server struct {
	BaseURL     string `json:"baseURL" yaml:"baseURL" default:"http://localhost"`
	Port        int    `json:"port" yaml:"port" default:"80"`
	Prefix      string `json:"prefix" yaml:"prefix" default:"/api/v1"`
	Debug       bool   `json:"debug" yaml:"debug" default:"false"`
	GracePeriod int    `json:"gracePeriod" yaml:"gracePeriod" default:"30"`
	PluginPath  string `json:"pluginPath" yaml:"pluginPath" default:"./_plugins"`
}

Jump to

Keyboard shortcuts

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