web

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2021 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

* @Author: Malin Xie * @Description: * @Date: 2021-07-26 14:25:51

* @Author: Malin Xie * @Description: * @Date: 2021-07-26 14:40:41

* web entrance file. process all http reqeust and response action * @Author: Malin Xie * @Description: * @Date: 2021-07-26 12:34:45

* @Author: Malin Xie * @Description: * @Date: 2021-07-07 17:39:12

Index

Constants

View Source
const (
	Default_PrefixPath = "/___"
	BlotFile           = "server.data"
	Bucket_Name        = "baidurpc_bucket"

	ErrorCode = -1
)
View Source
const (
	Default_Timeout = 10 * time.Second
)

Variables

View Source
var (
	Use_Embed_Mode = true
)

Functions

func LoadData

func LoadData(db *bolt.DB, bucketName string, page, pagesize int) (map[string][]byte, int64, error)

LoadData load all data from bbolt db by pagination supports

Types

type IntSort

type IntSort []int64

func (IntSort) Len

func (s IntSort) Len() int

func (IntSort) Less

func (s IntSort) Less(i, j int) bool

func (IntSort) Swap

func (s IntSort) Swap(i, j int)

type RPCMethodList

type RPCMethodList []*baidurpc.RPCMethod

func (RPCMethodList) Len

func (s RPCMethodList) Len() int

func (RPCMethodList) Less

func (s RPCMethodList) Less(i, j int) bool

func (RPCMethodList) Swap

func (s RPCMethodList) Swap(i, j int)

type ResponseData

type ResponseData struct {
	ErrNo   int         `json:"errno"`
	Message string      `json:"message,omitempty"`
	Data    interface{} `json:"data,omitempty"`
}

ResponseData standard web response struct to front end.

type RpcInfoList

type RpcInfoList []RpcOptions

func (RpcInfoList) Len

func (s RpcInfoList) Len() int

func (RpcInfoList) Less

func (s RpcInfoList) Less(i, j int) bool

func (RpcInfoList) Swap

func (s RpcInfoList) Swap(i, j int)

type RpcOptions

type RpcOptions struct {
	Name    string    `json:"name,omitempty"`
	Host    string    `json:"host,omitempty"`
	Port    int       `json:"port,omitempty"`
	Date    time.Time `json:"date,omitempty"`
	DateStr string    `json:"datestr,omitempty"`
}

type TemplateFS

type TemplateFS struct {
	Content     embed.FS
	Embbed      bool
	Current     string
	DelimsLeft  string
	DelimsRigth string
}

template FS mock

func (TemplateFS) Parse

func (t TemplateFS) Parse(engine *gin.Engine, nonEmbedPath string, patterns ...string) error

type WebDir

type WebDir struct {
	Prefix      string
	EmbedPrefix string
	Content     embed.FS
	Embbed      bool
}

func (WebDir) Open

func (d WebDir) Open(name string) (http.File, error)

Open implments Open method

type WebModule

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

WebModule web module entrance

func NewWebModule

func NewWebModule(listenAddr string, prefixPath string, datadir string) (*WebModule, error)

NewWebModule create a new web module.

func NewWebModuleWithListener

func NewWebModuleWithListener(l net.Listener, prefixPath string, datadir string) (*WebModule, error)

NewWebModule create a new web module.

func (*WebModule) AddRPCServer

func (wm *WebModule) AddRPCServer(name string, host string, port int) error

AddRPCServer

func (*WebModule) Close

func (wm *WebModule) Close()

Close do close bblot db

func (*WebModule) StartWeb

func (wm *WebModule) StartWeb() *http.Server

StartWeb

func (*WebModule) StartWebAndBlock

func (wm *WebModule) StartWebAndBlock()

StartWebAndBlock

Jump to

Keyboard shortcuts

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