nako

package module
v0.0.0-...-367bf2f Latest Latest
Warning

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

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

README

Nako

GoDoc Go Report Card

A lightweight go web framework.

Skeleton Repo

Create Project

go get github.com/gookit/nako/cmd/nako

// create new project
nako new:app my-project ./

Flow

Start boot

LICENSE

MIT

Documentation

Index

Constants

View Source
const (
	OnBeforeBoot = "app.boot.before"
	OnAfterBoot  = "app.boot.after"

	OnBeforeConfig = "app.config.before"
	OnAfterConfig  = "app.config.after"

	OnBeforeConsole = "app.console.before"
	OnAfterConsole  = "app.console.after"

	OnBeforeRoute = "app.route.before"
	OnAfterRoute  = "app.route.after"
)

Some app event names

View Source
const (
	ModeDev  mode = "dev"
	ModeTest mode = "test"
	ModeProd mode = "prod"
)

Variables

View Source
var (
	Debug = false
	Mode  = ModeDev
)

Functions

func Cache

func Cache() cache.Cache

Cache get

func Config

func Config() *config.Config

Router get

func Redis

func Redis()

func Router

func Router() *rux.Router

Router get from global app

func SetDefaultApp

func SetDefaultApp(app *Application)

SetGlobal app instance

func SetMode

func SetMode(name mode)

SetMode set run mode

Types

type Application

type Application struct {
	*event.Manager

	Name string

	BootLoaders []BootLoader

	// components
	View   *view.Renderer
	Cache  cache.Cache
	Config *config.Config
	Router *rux.Router
	Logger *slog.Logger
	// contains filtered or unexported fields
}

Application instance

func App

func App() *Application

App get application instance

func DefaultApp

func DefaultApp() *Application

DefaultApp get application instance

func NewApp

func NewApp() *Application

NewApp new application instance

func (*Application) Get

func (a *Application) Get(name string) interface{}

Get component from app.components

func (*Application) Run

func (a *Application) Run()

Run the application Usage:

app.Run()

func (*Application) Set

func (a *Application) Set(name string, val interface{})

Set component to app.components

type BootFunc

type BootFunc func(app *Application) error

BootFunc for application

func (BootFunc) Boot

func (fn BootFunc) Boot(app *Application) error

Boot do something

type BootLoader

type BootLoader interface {
	// Boot do something before application run
	Boot(app *Application) error
}

BootLoader for app start boot

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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