common

package
v0.0.0-...-def9258 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//JWTAlgorithmHS256 specifies the algorithm name for HS256.
	JWTAlgorithmHS256 = "HS256"
	//JWTAlgorithmHS384 specifies the algorithm name for HS384.
	JWTAlgorithmHS384 = "HS384"
	//JWTAlgorithmHS512 specifies the algorithm name for HS512.
	JWTAlgorithmHS512 = "HS512"
)
View Source
const (
	// DefaultPageSize defines the default page size.
	DefaultPageSize = 10
)
View Source
const (
	// RoleAdmin is the string constant for identifying a user with admin privileges.
	RoleAdmin = "ADMIN"
)

Variables

This section is empty.

Functions

func InitializeConfig

func InitializeConfig(release bool)

InitializeConfig loads the application configuration using environment properties respecting '.env' file.

func RandomString

func RandomString(n int) string

RandomString return a string of the form '[a-zA-Z0-9]{n}'.

Types

type Configuration

type Configuration struct {
	// contains filtered or unexported fields
}

Configuration is a struct which holds all configurable properties.

func Config

func Config() *Configuration

Config returns the singleton config instance.

func (*Configuration) GetDataPath

func (c *Configuration) GetDataPath() string

GetDataPath gets the base path for storing documents.

func (*Configuration) GetDatabaseType

func (c *Configuration) GetDatabaseType() string

GetDatabaseType gets the configured type of database. Can be 'sqlite3', 'postgres' or 'mysql'.

func (*Configuration) GetDatabaseURL

func (c *Configuration) GetDatabaseURL() *url.URL

GetDatabaseURL returns the URL for establishing the connection to the database.

func (*Configuration) GetJWTAlgorithm

func (c *Configuration) GetJWTAlgorithm() string

GetJWTAlgorithm gets the configured algorithm for issueing and verifying JWTs.

func (*Configuration) GetJWTExpirationTime

func (c *Configuration) GetJWTExpirationTime() time.Duration

GetJWTExpirationTime gets the expiration time of access tokens.

func (*Configuration) GetJWTKey

func (c *Configuration) GetJWTKey() []byte

GetJWTKey gets the configured encryption/decryption key for issueing and verifying JWTs.

func (*Configuration) GetJWTRefreshTime

func (c *Configuration) GetJWTRefreshTime() time.Duration

GetJWTRefreshTime gets the expiration time of refresh tokens.

func (*Configuration) GetPort

func (c *Configuration) GetPort() int

GetPort gets the configured listening port of the HTTP server.

func (*Configuration) GetPublicURL

func (c *Configuration) GetPublicURL() *url.URL

GetPublicURL gets the configured server base URL for public access.

func (*Configuration) IsDevelopment

func (c *Configuration) IsDevelopment() bool

IsDevelopment returns a boolean value indicating whether the development profile is currently active.

Development profile is only recognized as active when 'production' profile is not set.

func (*Configuration) IsProduction

func (c *Configuration) IsProduction() bool

IsProduction returns a boolean value indicating whether the development profile is currently active.

func (*Configuration) IsProfileActive

func (c *Configuration) IsProfileActive(profile string) bool

IsProfileActive checks whether the given profile is configured as active.

func (*Configuration) MigrateDatabase

func (c *Configuration) MigrateDatabase() bool

MigrateDatabase returns a boolean value indicating whether the migrations should be run.

type PageRequest

type PageRequest struct {
	Offset int `form:"offset"`
	Size   int `form:"size"`
}

PageRequest defines a struct for declaring pagin information for requests.

type Validator

type Validator struct {
	Validator *validator.Validate
}

Validator definess a struct for validating objects.

func (Validator) Validate

func (cv Validator) Validate(i interface{}) error

Validate validates the given object based on its constraints.

Jump to

Keyboard shortcuts

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