Documentation ¶
Overview ¶
Package cors provides handlers to enable CORS support.
Package expvar provides a standardized interface to public variables, such as operation counters in servers. It exposes these variables via HTTP at /debug/vars in JSON format.
Operations to set or modify these public variables are atomic.
In addition to adding the HTTP handler, this package registers the following variables:
cmdline os.Args memstats runtime.Memstats
The package is sometimes only imported for the side effect of registering its HTTP handler and the above variables. To use it this way, link this package into your program:
import _ "expvar"
Package pprof serves via its HTTP server runtime profiling data in the format expected by the pprof visualization tool. For more information about pprof, see http://code.google.com/p/google-perftools/.
The package is typically only imported for the side effect of registering its HTTP handlers. The handled paths all begin with /debug/pprof/.
To use pprof, link this package into your program:
import _ "net/http/pprof"
If your application is not already running an http server, you need to start one. Add "net/http" and "log" to your imports and the following code to your main function:
go func() { log.Println(http.ListenAndServe("localhost:6060", nil)) }()
Then use the pprof tool to look at the heap profile:
go tool pprof http://localhost:6060/debug/pprof/heap
Or to look at a 30-second CPU profile:
go tool pprof http://localhost:6060/debug/pprof/profile
Or to look at the goroutine blocking profile:
go tool pprof http://localhost:6060/debug/pprof/block
To view all available profiles, open http://localhost:6060/debug/pprof/ in your browser.
For a study of the facility in action, visit
http://blog.golang.org/2011/06/profiling-go-programs.html
Index ¶
- Variables
- func Allow(opts *Options) http.HandlerFunc
- func Cmdline(w http.ResponseWriter, r *http.Request)
- func Do(f func(KeyValue))
- func Index(w http.ResponseWriter, r *http.Request)
- func MD5(value string) string
- func Profile(w http.ResponseWriter, r *http.Request)
- func Publish(name string, v Var)
- func Symbol(w http.ResponseWriter, r *http.Request)
- func WalkDir(dirPth, suffix string) (files []string, err error)
- type DB
- func (this *DB) Close()
- func (this *DB) DB() *sql.DB
- func (this *DB) Exec(sqlstr string, args ...interface{}) (int64, error)
- func (this *DB) FetchRow(sqlstr string, args ...interface{}) (map[string]string, error)
- func (this *DB) FetchRows(sqlstr string, args ...interface{}) ([]map[string]string, error)
- func (this *DB) Insert(sqlstr string, args ...interface{}) (int64, error)
- func (this *DB) Open(db_user, db_pwd, db_host, db_database string)
- type Float
- type Func
- type GLWeb
- func (self *GLWeb) DB(db_user, db_pwd, db_host, db_database string)
- func (self *GLWeb) FileCreate(file *filemonitor.FileEntry)
- func (self *GLWeb) FileDelete(file *filemonitor.FileEntry)
- func (self *GLWeb) FileModify(file *filemonitor.FileEntry)
- func (self *GLWeb) Run(hp string)
- func (self *GLWeb) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type Int
- type KeyValue
- type Map
- type Options
- type RouteMatch
- type String
- type Task
- type Tasks
- type Var
Constants ¶
This section is empty.
Variables ¶
var BasicRealm = "GLWEB API Authorization"
Functions ¶
func Allow ¶
func Allow(opts *Options) http.HandlerFunc
Allow enables CORS for requests those match the provided options.
func Cmdline ¶
func Cmdline(w http.ResponseWriter, r *http.Request)
Cmdline responds with the running program's command line, with arguments separated by NUL bytes. The package initialization registers it as /debug/pprof/cmdline.
func Do ¶
func Do(f func(KeyValue))
Do calls f for each exported variable. The global variable map is locked during the iteration, but existing entries may be concurrently updated.
func Index ¶
func Index(w http.ResponseWriter, r *http.Request)
Index responds with the pprof-formatted profile named by the request. For example, "/debug/pprof/heap" serves the "heap" profile. Index responds to a request for "/debug/pprof/" with an HTML page listing the available profiles.
func Profile ¶
func Profile(w http.ResponseWriter, r *http.Request)
Profile responds with the pprof-formatted cpu profile. The package initialization registers it as /debug/pprof/profile.
func Publish ¶
Publish declares a named exported variable. This should be called from a package's init function when it creates its Vars. If the name is already registered then this will log.Panic.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
type Float ¶
type Float struct {
// contains filtered or unexported fields
}
Float is a 64-bit float variable that satisfies the Var interface.
type Func ¶
type Func func() interface{}
Func implements Var by calling the function and formatting the returned value using JSON.
type GLWeb ¶
type GLWeb struct { filemonitor.FileMonitorAdaptor // contains filtered or unexported fields }
func (*GLWeb) FileCreate ¶
func (self *GLWeb) FileCreate(file *filemonitor.FileEntry)
func (*GLWeb) FileDelete ¶
func (self *GLWeb) FileDelete(file *filemonitor.FileEntry)
func (*GLWeb) FileModify ¶
func (self *GLWeb) FileModify(file *filemonitor.FileEntry)
type Int ¶
type Int struct {
// contains filtered or unexported fields
}
Int is a 64-bit integer variable that satisfies the Var interface.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map is a string-to-Var map variable that satisfies the Var interface.
type Options ¶
type Options struct { // If set, all origins are allowed. AllowAllOrigins bool // A list of allowed origins. Wild cards and FQDNs are supported. AllowOrigins []string // If set, allows to share auth credentials such as cookies. AllowCredentials bool // A list of allowed HTTP methods. AllowMethods []string // A list of allowed HTTP headers. AllowHeaders []string // A list of exposed HTTP headers. ExposeHeaders []string // Max age of the CORS headers. MaxAge time.Duration }
Options represents Access Control options.
func (*Options) IsOriginAllowed ¶
IsOriginAllowed looks up if the origin matches one of the patterns generated from Options.AllowOrigins patterns.
type RouteMatch ¶
type RouteMatch int
const ( NoMatch RouteMatch = iota StarMatch OverloadMatch ExactMatch )
func (RouteMatch) BetterThan ¶
func (r RouteMatch) BetterThan(o RouteMatch) bool
Higher number = better match
type String ¶
type String struct {
// contains filtered or unexported fields
}
String is a string variable, and satisfies the Var interface.