gtea

package module
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: MIT Imports: 13 Imported by: 8

README

Gtea

Godoc

Description

gtea (short for green tea) is a web framework.

Documentation

Index

Constants

View Source
const (
	DevEnv  = "development"
	DevPort = 8080
)

DevEnv const

Variables

This section is empty.

Functions

This section is empty.

Types

type App added in v0.0.4

type App struct {
	Logger *jsonlog.Logger
	// contains filtered or unexported fields
}

App is the main application object.

func DefaultApp added in v0.0.5

func DefaultApp() *App

DefaultApp is the default application object.

func NewApp

func NewApp(ctx context.Context, cfg *Config) *App

NewApp creates a new application object.

func (*App) AddBGJob added in v0.3.5

func (app *App) AddBGJob(name string, fn func(context.Context, chan<- Message)) error

AddBGJob start a background job, goroutine safe

func (*App) AddClearFn added in v0.3.7

func (app *App) AddClearFn(fn func())

AddClearFn add defer func in app.shutdown you may add db.close, redis.close, etc not goroutine safe

func (*App) AddMetaData added in v0.0.7

func (a *App) AddMetaData(key string, value string)

AddMetaData adds meta data to the application by key.

func (*App) Env added in v0.5.6

func (a *App) Env() string

Env returns config environment

func (*App) FireAnonymousJob added in v0.4.24

func (app *App) FireAnonymousJob(fn func(context.Context))

FireAnonymousJob start a background job, goroutine safe

func (*App) GetBGChan added in v0.3.5

func (app *App) GetBGChan(name string) <-chan Message

GetBGChan get backgroud job receive only feedback chan goroutine safe

func (*App) GetBGJobParam added in v0.4.1

func (app *App) GetBGJobParam(name string) *JobParam

GetBGJobParam get backgroud job param goroutine safe

func (*App) GetMetaData added in v0.0.7

func (a *App) GetMetaData(key string) string

GetMetaData returns the meta data of the application by key.

func (*App) Serve added in v0.0.4

func (app *App) Serve(ctx context.Context, routes http.Handler) error

Serve start http server

func (*App) ServeTLS added in v0.5.0

func (app *App) ServeTLS(ctx context.Context, routes http.Handler, cert, pKey string) error

Serve start https server with cert private PEM encode file

func (*App) Shutdown added in v0.0.4

func (app *App) Shutdown()

Shutdown call clearFns one by one

type Config

type Config struct {
	Port           int
	Env            string
	Metrics        bool
	LogLevel       jsonlog.Level
	NoWirteTimeout bool
}

Config is the configuration for the application

func DefaultConfig added in v0.0.5

func DefaultConfig() *Config

DefaultConfig is the default configuration for the application

type JobParam added in v0.4.0

type JobParam struct {
	Chan   chan Message
	Cancle context.CancelFunc
}

JobParam ...

type Message added in v0.3.6

type Message struct {
	Payload any
	Err     error
}

Message chan feedback

Directories

Path Synopsis
sse

Jump to

Keyboard shortcuts

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