Documentation
¶
Index ¶
- Constants
- Variables
- func Abort(w http.ResponseWriter, message string, code int)
- func GetQueryInt(r *http.Request, key string, defaultValue int) int
- func GetQueryInt32(r *http.Request, key string, defaultValue uint32) uint32
- func Hash(file string) (s string)
- func InitConfig(filepath string) error
- func JwtNewToken(connection Connection, issuer string) (tokenString string, expire int64, err error)
- func MemStatic(staticDir string)
- func ModTime(file string) (t time.Time)
- func Open(name string) (io.ReadCloser, error)
- func ServeHTTP(rw http.ResponseWriter, req *http.Request)
- func ServeJSON(w http.ResponseWriter, j interface{})
- type Claims
- type Connection
- type Node
- type SSHConnInterface
- type SSHShellChannel
- type SSHShellSession
- type Session
- type SessionManager
Constants ¶
const ( SSH_IO_MODE_CHANNEL = 0 SSH_IO_MODE_SESSION = 1 )
Variables ¶
var Config struct { Site struct { AppName string `yaml:"app_name"` RunMode string `yaml:"runmode"` DeployHost string `yaml:"deploy_host"` ListenAddr string `yaml:"listen_addr"` } `yaml:"site"` Prod struct { StaticPrefix string `yaml:"static_prefix"` // http prefix of static and views files } `yaml:"prod"` Dev struct { StaticPrefix string `yaml:"static_prefix"` // https prefix of only static files //StaticPrefix string `yaml:"static_prefix"` // prefix of static files in dev mode. // redirect static files requests to this address, redirect "StaticPrefix" to "StaticRedirect + StaticPrefix" // for example, StaticPrefix is "static", StaticRedirect is "localhost:8080/dist", // this will redirect all requests having prefix "static" to "localhost:8080/dist/" StaticRedirect string `yaml:"static_redirect"` // http server will read static file from this dir if StaticRedirect is empty StaticDir string `yaml:"static_dir"` ViewsPrefix string `yaml:"views_prefix"` // https prefix of only views files // path of view files (we can not redirect view files) to be served. ViewsDir string `yaml:"views_dir"` // todo } `yaml:"dev"` SSH struct { BufferCheckerCycleTime int `yaml:"buffer_checker_cycle_time"` } `yaml:"ssh"` Jwt struct { Secret string `yaml:"jwt_secret"` TokenLifetime int64 `yaml:"token_lifetime"` Issuer string `yaml:"issuer"` QueryTokenKey string `yaml:"query_token_key"` } `yaml:"jwt"` }
var NotFound = http.NotFound
NotFound is called when no asset is found. It defaults to http.NotFound but can be overwritten
var Server http.Handler = http.HandlerFunc(ServeHTTP)
Server is simply ServeHTTP but wrapped in http.HandlerFunc so it can be passed into net/http functions directly.
Functions ¶
func Hash ¶
Hash returns the hex-encoded SHA256 hash of the original file Used for the Etag, and useful for caching Returns an empty string if the file is not in the bundle
func InitConfig ¶ added in v0.2.0
func JwtNewToken ¶
func JwtNewToken(connection Connection, issuer string) (tokenString string, expire int64, err error)
create a jwt token,and return this token as string type.
func MemStatic ¶ added in v0.2.0
func MemStatic(staticDir string)
read all files in views directory and map to "staticFiles"
func ModTime ¶
ModTime returns the modification time of the original file. Useful for caching purposes Returns zero time if the file is not in the bundle
func Open ¶
func Open(name string) (io.ReadCloser, error)
Open allows you to read an embedded file directly. It will return a decompressing Reader if the file is embedded in compressed format. You should close the Reader after you're done with it.
func ServeHTTP ¶
func ServeHTTP(rw http.ResponseWriter, req *http.Request)
ServeHTTP serves a request, attempting to reply with an embedded file.
func ServeJSON ¶
func ServeJSON(w http.ResponseWriter, j interface{})
Types ¶
type Claims ¶
type Claims struct { Connection jwt.StandardClaims }
type Connection ¶
type Connection Node // struct alias.
type Node ¶
type Node struct { Host string // host, e.g: ssh.example.com Port int //port,default value is 22 // contains filtered or unexported fields }
func (*Node) Connect ¶
see: http://www.nljb.net/default/Go-SSH-%E4%BD%BF%E7%94%A8/ establish a ssh connection. if success return nil, than can operate ssh connection via pointer SSH.client in struct SSH.
type SSHConnInterface ¶
type SSHShellChannel ¶
deprecated, use session SSHShellSession instead connect to ssh server using channel.
func (*SSHShellChannel) Config ¶
func (ch *SSHShellChannel) Config(cols, rows uint32) error
type SSHShellSession ¶
type SSHShellSession struct { Node // calling Write() to write data to ssh server StdinPipe io.WriteCloser // Write() be called to receive data from ssh server WriterPipe io.Writer Session *ssh.Session }
connect to ssh server using ssh session.
func (*SSHShellSession) Close ¶
func (s *SSHShellSession) Close()
func (*SSHShellSession) Config ¶
func (s *SSHShellSession) Config(cols, rows uint32) error
setup ssh shell session set Session and StdinPipe here, and the Session.Stdout and Session.Sdterr are also set.
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
use jwt string as session key, store user information(username and password) in Session.
var SessionStorage SessionManager
func (*SessionManager) Delete ¶
func (s *SessionManager) Delete(key string)
func (*SessionManager) Get ¶
func (s *SessionManager) Get(key string) (sessionData Session, exist bool)
func (*SessionManager) Put ¶
func (s *SessionManager) Put(key string, expire int64, value interface{})
* * add a new session to session manager. * @params:token: token string * expire: unix time for expire * password: ssh user password