firewood

package module
v0.0.0-...-861e52b Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2019 License: MIT Imports: 16 Imported by: 0

README

firewood

Firewood is a web framework written in Go.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Db *sql.DB
View Source
var Log = logrus.New()

Functions

func InitLog

func InitLog(cnf *ServerConf) error

func InitMysql

func InitMysql(addr, user, password, database string) error

func InitPg

func InitPg(addr, user, password, database string) error

func New

func New(res http.ResponseWriter, req *http.Request, r T, methods ...string)

func RunServer

func RunServer(addr string, handler http.Handler) error

func Write

func Write(res http.ResponseWriter, req *http.Request, code int, data interface{})

Types

type CacheConf

type CacheConf struct {
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	PoolSize int    `yaml:"pool_size"`
	Password string `yaml:"password"`
}

type DbConf

type DbConf struct {
	User     string `yaml:"user"`
	Password string `yaml:"password"`
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	Database string `yaml:"database"`
	PoolSize int    `yaml:"pool_size"`
}

type HttpConf

type HttpConf struct {
	Port int `yaml:"port"`
}

type HttpTest

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

func NewHttpTest

func NewHttpTest(t *testing.T, req *http.Request) *HttpTest

func (*HttpTest) Do

func (ht *HttpTest) Do(r http.Handler, v interface{}) (*httptest.ResponseRecorder, error)

type ListOptions

type ListOptions struct {
	// For paginated result sets, page of results to retrieve.
	Offset int64 `url:"offset,omitempty"`
	// For paginated result sets, the number of results to include per page.
	Limit int64 `url:"limit,omitempty"`
}

ListOptions specifies the optional parameters to various List methods that support pagination.

type LoggerHandler

type LoggerHandler struct{}

func NewLoggerHandler

func NewLoggerHandler() *LoggerHandler

NewLoggerHandler returns a new LoggerHandler instance

func (*LoggerHandler) ServeHTTP

func (*LoggerHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type Server

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

type ServerConf

type ServerConf struct {
	AccessLog string `yaml:"access_log"`
	ErrorLog  string `yaml:"error_log"`
	LogLevel  string `yaml:"log_level"`

	Http  *HttpConf  `yaml:"http"`
	Db    *DbConf    `yaml:"db"`
	Cache *CacheConf `yaml:"cache"`
}
var Conf *ServerConf

func InitServerConf

func InitServerConf(file string) (*ServerConf, error)

type T

type T interface {
	FieldMap(req *http.Request) binding.FieldMap
	Do(res http.ResponseWriter, req *http.Request) (interface{}, int, error)
}

Jump to

Keyboard shortcuts

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