core

package
v0.0.0-...-abc1a05 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Defines and initiates a Configuration struct

Package core defines core API objects and functions (e.g. database, security and config methods). The file database.go defines the database object.

Index

Constants

This section is empty.

Variables

View Source
var Config = settings{
	Api: ApiConfig{
		Name:    getEnv("API_NAME", "go-api"),
		Version: getEnv("API_VERSION", "v1"),
		Mode:    getEnv("GIN_MODE", "debug"),
	},
	Server: ServerConfig{
		Host: getEnv("HOST", "0.0.0.0"),
		Port: getEnv("PORT", "8000"),
	},
	Database: DatabaseConfig{
		Dialect: getEnv("DATABASE_DIALECT", "sqlite"),
		Uri:     getEnv("DATABASE_URI", "main.db"),
	},
}

Config is public configuration object.

Functions

func NewHTTPError

func NewHTTPError(ctx *gin.Context, status int, err error)

NewError example

func NewId

func NewId() string

Newid returns a base64 encoded uuid.

Types

type ApiConfig

type ApiConfig struct {
	Name    string
	Version string
	Mode    string
}

type DatabaseConfig

type DatabaseConfig struct {
	Dialect string
	Uri     string
}

type DatabaseI

type DatabaseI interface {
	Connect()
	Migrate(models []interface{})
	Orm() *gorm.DB
}

func NewDatabase

func NewDatabase(dialect string, uri string) DatabaseI

NewDatabase is the database struct constructor.

type HTTPError

type HTTPError struct {
	Code    int    `json:"code" example:"400"`
	Message string `json:"message" example:"status bad request"`
}

HTTPError example

type HTTPSuccess

type HTTPSuccess struct {
	Code    int    `json:"code" example:"200"`
	Message string `json:"message" example:"request completed"`
}

HTTPError example

type ServerConfig

type ServerConfig struct {
	Host string
	Port string
}

Jump to

Keyboard shortcuts

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