dawn

package module
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "0.3.3"

Version of current dawn package

Variables

This section is empty.

Functions

This section is empty.

Types

type Cleanup

type Cleanup func()

Cleanup is a function does cleanup works

type Module

type Module struct{}

Module is an empty struct implements Moduler interface and can be embedded into custom struct as a Moduler

func (Module) Boot

func (Module) Boot()

Boot boots the module.

func (Module) Init

func (Module) Init() Cleanup

Init does initialization works and should return a cleanup function.

func (Module) RegisterRoutes

func (Module) RegisterRoutes(fiber.Router)

RegisterRoutes add routes to fiber router

func (Module) String

func (Module) String() string

String indicates module's name

type Moduler

type Moduler interface {
	// Stringer indicates module's name
	fmt.Stringer

	// Init does initialization works and should return
	// a cleanup function.
	Init() Cleanup

	// Boot boots the module.
	Boot()

	// RegisterRoutes add routes to fiber router
	RegisterRoutes(fiber.Router)
}

Moduler is the interface that wraps the module's method.

type Option

type Option func(s *Sloop)

Option can be applied in server

func App

func App(app *fiber.App) Option

App option sets custom Fiber App to Sloop

func Modulers

func Modulers(mods ...Moduler) Option

Modulers option adds several Modulers to server

type Sloop

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

Sloop denotes Dawn application

func Default

func Default(cfg ...fiber.Config) *Sloop

Default returns an Sloop instance with the - RequestID - Logger - Recovery - Pprof middleware already attached in default fiber app.

func New

func New(opts ...Option) *Sloop

New returns a new Sloop with options.

func (*Sloop) AddModulers

func (s *Sloop) AddModulers(m ...Moduler)

AddModulers appends more Modulers

func (*Sloop) Cleanup

func (s *Sloop) Cleanup()

Cleanup releases resources

func (*Sloop) Router

func (s *Sloop) Router() fiber.Router

Router returns the server router

func (*Sloop) Run

func (s *Sloop) Run(addr string) error

Run runs a web server

func (*Sloop) RunTls

func (s *Sloop) RunTls(addr, certFile, keyFile string) error

RunTls runs a tls web server

func (*Sloop) Setup

func (s *Sloop) Setup() *Sloop

Setup initializes all modules and then boots them

func (*Sloop) Shutdown

func (s *Sloop) Shutdown() error

Shutdown gracefully shuts down the server without interrupting any active connections.

func (*Sloop) Watch

func (s *Sloop) Watch()

Watch listens to signal to exit

Directories

Path Synopsis
_examples
application command
config command
custom_app command
log command
quickstart command
cmd
dawn command
db
sql

Jump to

Keyboard shortcuts

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