Documentation ¶
Index ¶
- Constants
- Variables
- func RequestFileByRange(fullPath string, writer http.ResponseWriter, request *http.Request)
- func ToHtmlTable(data interface{}) string
- func ToSnakeName(name string) string
- type Client
- type Command
- type ConsoleService
- func (my *ConsoleService) Command(ctx context.Context, request *commandRqt) (*Response, error)
- func (my *ConsoleService) Hint(ctx context.Context, request *hintRqt) ([]byte, error)
- func (my *ConsoleService) Sub(ctx context.Context, request *subRqt) (*Response, error)
- func (my *ConsoleService) Unsub(ctx context.Context, request *subRqt) (*Response, error)
- type IServeMux
- type Response
- type Server
- type ServerOption
- func WithAutoLoginTime(d time.Duration) ServerOption
- func WithDeadlockIgnores(ignores []string) ServerOption
- func WithDirectory(path string) ServerOption
- func WithEnablePProf(enable bool) ServerOption
- func WithLogListRoot(path string) ServerOption
- func WithPageBody(body string) ServerOption
- func WithPageTemplate(path string) ServerOption
- func WithPageTitle(title string) ServerOption
- func WithPort(port int) ServerOption
- func WithUserPasswords(passwords map[string]string) ServerOption
- func WithWebSocketPath(path string) ServerOption
- type Topic
Constants ¶
const ( FlagPublic = 0x0002 // 不需要登录就可以使用的命令 FlagInvisible = 0x0004 // 在inputBox中无法看到和使用的命令 )
Variables ¶
var AppBuildTime string // 应用构建时间: date +%Y-%m-%dT%H:%M:%S
var GitBranchName string // git分支名: git rev-parse --abbrev-ref HEAD
GitBranchName 参考:《编译时向 go 程序写入 git 版本信息》 http://mengqi.info/html/2015/201502171941-build-go-program-with-git-version.html
IMPORT_PATH=github.com/lixianmin/gonsole FLAGS="-w -s -X $IMPORT_PATH.GitBranchName=`git rev-parse --abbrev-ref HEAD` -X $IMPORT_PATH.GitCommitId=`git log --pretty=format:\"%h\" -1` -X '$IMPORT_PATH.GitCommitMessage=`git show -s --format=%s`' -X $IMPORT_PATH.GitCommitTime=`git log --date=format:'%Y-%m-%dT%H:%M:%S' --pretty=format:%ad -1` -X $IMPORT_PATH.AppBuildTime=`date +%Y-%m-%dT%H:%M:%S`" go build -ldflags "$FLAGS" -mod vendor -gcflags "-N -l"
var GitCommitId string // git提交id: git log --pretty=format:\"%h\" -1
var GitCommitMessage string // git提交的message: git show -s --format=%s
var GitCommitTime string // git提交的时间: git log --date=format:'%Y-%m-%dT%H:%M:%S' --pretty=format:%ad -1
Functions ¶
func RequestFileByRange ¶
func RequestFileByRange(fullPath string, writer http.ResponseWriter, request *http.Request)
RequestFileByRange https://delveshal.github.io/2018/05/17/golang-%E5%AE%9E%E7%8E%B0%E6%96%87%E4%BB%B6%E6%96%AD%E7%82%B9%E7%BB%AD%E4%BC%A0-demo/
func ToHtmlTable ¶
func ToHtmlTable(data interface{}) string
func ToSnakeName ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Attachment ¶
func (client *Client) Attachment() road.Attachment
func (*Client) PushDefault ¶
func (client *Client) PushDefault(v interface{})
type Command ¶
type Command struct { loom.Flag // command的flag Name string // 名称 Note string // 描述 Handler func(client *Client, args []string) (*Response, error) // 处理方法 }
func (*Command) IsInvisible ¶
type ConsoleService ¶
type ConsoleService struct {
// contains filtered or unexported fields
}
func (*ConsoleService) Command ¶
func (my *ConsoleService) Command(ctx context.Context, request *commandRqt) (*Response, error)
func (*ConsoleService) Hint ¶
func (my *ConsoleService) Hint(ctx context.Context, request *hintRqt) ([]byte, error)
type IServeMux ¶
type IServeMux interface {
HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
}
type Response ¶
type Response struct { Operation string `json:"op"` Data interface{} `json:"data"` }
func NewDefaultResponse ¶
func NewDefaultResponse(data interface{}) *Response
func NewEmptyResponse ¶
func NewEmptyResponse() *Response
func NewHtmlResponse ¶
func NewTableResponse ¶
func NewTableResponse(table interface{}) *Response
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(mux IServeMux, opts ...ServerOption) *Server
func (*Server) ConsoleUrl ¶
func (*Server) RegisterCommand ¶
func (*Server) RegisterService ¶
func (*Server) RegisterTopic ¶
type ServerOption ¶
type ServerOption func(*serverOptions)
func WithAutoLoginTime ¶
func WithAutoLoginTime(d time.Duration) ServerOption
WithAutoLoginTime 如果手动登录过,则在时限内自动登录
func WithDeadlockIgnores ¶
func WithDeadlockIgnores(ignores []string) ServerOption
WithDeadlockIgnores 死锁检查时可以忽略的调用字符串
func WithLogListRoot ¶
func WithLogListRoot(path string) ServerOption
WithLogListRoot log.list命令显示的日志文件根目录
func WithPageTemplate ¶
func WithPageTemplate(path string) ServerOption
WithPageTemplate 主页(console.html)模板文件的路径名
func WithUserPasswords ¶
func WithUserPasswords(passwords map[string]string) ServerOption
WithUserPasswords 可以登陆的用户名与密码
func WithWebSocketPath ¶
func WithWebSocketPath(path string) ServerOption
WithWebSocketPath websocket监听的路径