hemlock

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: MIT Imports: 12 Imported by: 0

README

About Hemlock

Hemlock is a web application framework for Go 1.9 or newer.

This project is still in the proof-of-concept phase so no peeking! 🙈🙈

Installation

go get github.com/gschier/hemlock

Getting Started

Create a new application in desired folder

hemlock new path/to/my/app

Build and run the sample app

hemlock serve --watch path/to/my/app

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CacheBustKey string

CacheBustKey is the cache busting key

Functions

func Env

func Env(name string) string

Env returns the value of the 'name'd environment variable or an empty string

func EnvOr

func EnvOr(name, fallback string) string

EnvOr will return the value for 'name' or the fallback if it doesn't exist

func EnvOrPanic

func EnvOrPanic(name string) string

EnvOrPanic will return the value for 'name' or panic if not present

func Version

func Version() string

Version returns the semver version number of the Hemlock framework

Types

type Application

type Application struct {
	Config *Config
	// contains filtered or unexported fields
}

func CloneApplication

func CloneApplication(app *Application) *Application

func NewApplication

func NewApplication(config *Config, providers []Provider) *Application

func (*Application) Bind

func (a *Application) Bind(fn interface{})

func (*Application) Env

func (a *Application) Env(name string) string

func (*Application) EnvOr

func (a *Application) EnvOr(name, fallback string) string

func (*Application) Instance

func (a *Application) Instance(v interface{})

func (*Application) IsDev

func (a *Application) IsDev() bool

func (*Application) IsProd

func (a *Application) IsProd() bool

func (*Application) Make

func (a *Application) Make(i interface{}) interface{}

func (*Application) Path

func (a *Application) Path(elem ...string) string

Path resolves an absolute path

func (*Application) Resolve

func (a *Application) Resolve(v ...interface{})

func (*Application) ResolveInto

func (a *Application) ResolveInto(fn interface{}, extraArgs ...interface{}) []interface{}

func (*Application) Singleton

func (a *Application) Singleton(fn interface{})

func (*Application) Start

func (a *Application) Start()

type Config

type Config struct {
	Name               string
	Env                string
	URL                string
	TemplatesDirectory string
	PublicDirectory    string
	PublicPrefix       string
	Database           *DatabaseConfig
	Sessions           *SessionConfig
	HTTP               *HTTPConfig
	Extra              []interface{}
}

Config contains the static configuration for a Hemlock application. There is an optional 'Extra' field for storing configuration not directly related to the core Hemlock functionality.

type DatabaseConfig

type DatabaseConfig struct {
	Default     string // 'postgres'
	Migrations  string // 'migrations'
	Connections []DatabaseConnectionConfig
}

DatabaseConfig contains database settings.

type DatabaseConnectionConfig

type DatabaseConnectionConfig struct {
	Driver    string
	Host      string
	Database  string
	Username  string
	Password  string
	Charset   string
	Collation string
	Prefix    string
	Schema    string
	SSLMode   bool
}

DatabaseConnectionConfig contains settings for connecting to DB instances.

type HTTPConfig

type HTTPConfig struct {
	Host string
	Port string
}

HTTPConfig contains server configuration.

type Provider

type Provider interface {
	// Register registers a new provider. Any setup should happen here
	Register(interfaces.Container)

	// Boot is called after all service providers have been registered
	Boot(*Application) error
}

type SessionConfig

type SessionConfig struct {
	Default     string // 'postgres'
	Migrations  string // 'migrations'
	Connections []DatabaseConnectionConfig
}

SessionConfig contains database settings.

Directories

Path Synopsis
cmd
internal
cli
support

Jump to

Keyboard shortcuts

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