server

package
v0.0.0-...-81b12a4 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2020 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMinioClient

func NewMinioClient(conf MinioConf) (client *minio.Client, err error)

NewMinioClient ...

func NewPostgreSQL

func NewPostgreSQL(conf DBConf) (db *gorm.DB, err error)

NewPostgreSQL ...

Types

type Admin

type Admin struct {
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

Admin ...

type Conf

type Conf struct {
	DB               DBConf   `yaml:"db"`
	CROSAllowOrigins []string `yaml:"cros_allow_origins"`
	StorageDir       string   `yaml:"storage_dir"`
	Web              struct {
		Port int `yaml:"port"`
		// Timeout config
		WriteTimeoutInSec time.Duration `yaml:"write_timeout_sec"`
		ReadTimeoutInSec  time.Duration `yaml:"read_timeout_sec"`
		ReadHeaderTimeout time.Duration `yaml:"read_header_timeout_sec"`
		IdleTimeoutInSec  time.Duration `yaml:"idle_timeout_sec"`
		ShutdownWaitInSec time.Duration `yaml:"shutdown_wait_sec"`
	} `yaml:"web"`
	CreateAdmin bool      `yaml:"create_admin"`
	Admin       Admin     `yaml:"admin"`
	Record      Record    `yaml:"record"`
	Minio       MinioConf `yaml:"minio"`
}

Conf ...

func LoadConf

func LoadConf(yamlPath string) (conf Conf, err error)

LoadConf load config from yaml

func (*Conf) Validate

func (c *Conf) Validate() (err error)

Validate ...

type DBConf

type DBConf struct {
	Database     string        `yaml:"database"`
	Username     string        `yaml:"username"`
	Password     string        `yaml:"password"`
	Port         int           `yaml:"port"`
	Host         string        `yaml:"host"`
	Reset        bool          `yaml:"reset"`
	ReconnectSec time.Duration `yaml:"reconnect_sec"`
}

DBConf ...

type MinioConf

type MinioConf struct {
	AccessKey string `yaml:"access_key"`
	SecretKey string `yaml:"secret_key"`
	EndPoint  string `yaml:"endpoint"`
	Secure    bool   `yaml:"secure"`
}

MinioConf ...

type Record

type Record struct {
	Code string `yaml:"code"`
	URL  string `yaml:"url"`
}

Record ...

type Server

type Server struct {
	HTTPHandler http.Handler
	Frontend    *packr.Box
	Conf        Conf
	DB          *gorm.DB
	TuShare     *tushare.TuShare
	Minio       *minio.Client
}

Server ...

func New

func New(conf Conf, frontend *packr.Box) (s *Server, err error)

New ...

func (*Server) CreateAccount

func (s *Server) CreateAccount(w http.ResponseWriter, r *http.Request)

CreateAccount ...

func (*Server) CreateTables

func (s *Server) CreateTables(values ...interface{}) (err error)

CreateTables create all tables

func (*Server) CreateUser

func (s *Server) CreateUser(username string, password string, role m.UserRole) (err error)

CreateUser ...

func (*Server) DeleteAccount

func (s *Server) DeleteAccount(w http.ResponseWriter, r *http.Request)

DeleteAccount ...

func (*Server) DropTables

func (s *Server) DropTables(values ...interface{}) (err error)

DropTables drop all tables

func (*Server) FetchAccounts

func (s *Server) FetchAccounts(w http.ResponseWriter, r *http.Request)

FetchAccounts ...

func (*Server) FetchRecord

func (s *Server) FetchRecord(w http.ResponseWriter, r *http.Request)

FetchRecord ...

func (*Server) Free

func (s *Server) Free()

Free ...

func (*Server) Login

func (s *Server) Login(w http.ResponseWriter, r *http.Request)

Login ...

func (*Server) Logout

func (s *Server) Logout(w http.ResponseWriter, r *http.Request)

Logout ...

func (*Server) MinioUpload

func (s *Server) MinioUpload(fp string, objName string, contentType string) (err error)

MinioUpload ...

func (*Server) ResetTables

func (s *Server) ResetTables(values ...interface{}) (err error)

ResetTables drop and create tables

func (*Server) StartOrDie

func (s *Server) StartOrDie() (err error)

StartOrDie ...

func (*Server) UpdateAccount

func (s *Server) UpdateAccount(w http.ResponseWriter, r *http.Request)

UpdateAccount ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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