Compare commits
6 Commits
master
...
release-br
Author | SHA1 | Date |
---|---|---|
|
f8f91591b7 | |
|
5849dad824 | |
|
161de53d86 | |
|
72b8aac9ec | |
|
4b93659ce3 | |
|
432822781f |
1
README
1
README
|
@ -8,3 +8,4 @@ Packages include a type-checker for Go and an implementation of the Single Stati
|
||||||
Assignment (SSA) representation for Go programs.
|
Assignment (SSA) representation for Go programs.
|
||||||
|
|
||||||
To submit changes to this repository, see http://golang.org/doc/contribute.html.
|
To submit changes to this repository, see http://golang.org/doc/contribute.html.
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ type Config struct {
|
||||||
|
|
||||||
HomeArticles int // Articles to display on the home page.
|
HomeArticles int // Articles to display on the home page.
|
||||||
FeedArticles int // Articles to include in Atom and JSON feeds.
|
FeedArticles int // Articles to include in Atom and JSON feeds.
|
||||||
|
FeedTitle string // The title of the Atom XML feed
|
||||||
|
|
||||||
PlayEnabled bool
|
PlayEnabled bool
|
||||||
}
|
}
|
||||||
|
@ -117,7 +118,7 @@ func NewServer(cfg Config) (*Server, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up content file server.
|
// Set up content file server.
|
||||||
s.content = http.FileServer(http.Dir(cfg.ContentPath))
|
s.content = http.StripPrefix(s.cfg.BasePath, http.FileServer(http.Dir(cfg.ContentPath)))
|
||||||
|
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
@ -258,11 +259,11 @@ func (s *Server) loadDocs(root string) error {
|
||||||
// atomFeed field.
|
// atomFeed field.
|
||||||
func (s *Server) renderAtomFeed() error {
|
func (s *Server) renderAtomFeed() error {
|
||||||
var updated time.Time
|
var updated time.Time
|
||||||
if len(s.docs) > 1 {
|
if len(s.docs) > 0 {
|
||||||
updated = s.docs[0].Time
|
updated = s.docs[0].Time
|
||||||
}
|
}
|
||||||
feed := atom.Feed{
|
feed := atom.Feed{
|
||||||
Title: "The Go Programming Language Blog",
|
Title: s.cfg.FeedTitle,
|
||||||
ID: "tag:" + s.cfg.Hostname + ",2013:" + s.cfg.Hostname,
|
ID: "tag:" + s.cfg.Hostname + ",2013:" + s.cfg.Hostname,
|
||||||
Updated: atom.Time(updated),
|
Updated: atom.Time(updated),
|
||||||
Link: []atom.Link{{
|
Link: []atom.Link{{
|
||||||
|
|
|
@ -72,7 +72,7 @@ func main() {
|
||||||
|
|
||||||
<div id="footer">
|
<div id="footer">
|
||||||
Build version {{html .Version}}.<br>
|
Build version {{html .Version}}.<br>
|
||||||
Except as <a href="http://code.google.com/policies.html#restrictions">noted</a>,
|
Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
|
||||||
the content of this page is licensed under the
|
the content of this page is licensed under the
|
||||||
Creative Commons Attribution 3.0 License,
|
Creative Commons Attribution 3.0 License,
|
||||||
and code is licensed under a <a href="/LICENSE">BSD license</a>.<br>
|
and code is licensed under a <a href="/LICENSE">BSD license</a>.<br>
|
||||||
|
|
|
@ -222,7 +222,7 @@ func main() {
|
||||||
|
|
||||||
<div id="footer">
|
<div id="footer">
|
||||||
Build version {{html .Version}}.<br>
|
Build version {{html .Version}}.<br>
|
||||||
Except as <a href="http://code.google.com/policies.html#restrictions">noted</a>,
|
Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
|
||||||
the content of this page is licensed under the
|
the content of this page is licensed under the
|
||||||
Creative Commons Attribution 3.0 License,
|
Creative Commons Attribution 3.0 License,
|
||||||
and code is licensed under a <a href="/LICENSE">BSD license</a>.<br>
|
and code is licensed under a <a href="/LICENSE">BSD license</a>.<br>
|
||||||
|
|
|
@ -22,6 +22,8 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -35,9 +37,6 @@ import (
|
||||||
"code.google.com/p/go.net/websocket"
|
"code.google.com/p/go.net/websocket"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Handler implements a WebSocket handler for a client connection.
|
|
||||||
var Handler = websocket.Handler(socketHandler)
|
|
||||||
|
|
||||||
// Environ provides an environment when a binary, such as the go tool, is
|
// Environ provides an environment when a binary, such as the go tool, is
|
||||||
// invoked.
|
// invoked.
|
||||||
var Environ func() []string = os.Environ
|
var Environ func() []string = os.Environ
|
||||||
|
@ -65,6 +64,30 @@ type Options struct {
|
||||||
Race bool // use -race flag when building code (for "run" only)
|
Race bool // use -race flag when building code (for "run" only)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewHandler returns a websocket server which checks the origin of requests.
|
||||||
|
func NewHandler(origin *url.URL) websocket.Server {
|
||||||
|
return websocket.Server{
|
||||||
|
Config: websocket.Config{Origin: origin},
|
||||||
|
Handshake: handshake,
|
||||||
|
Handler: websocket.Handler(socketHandler),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// handshake checks the origin of a request during the websocket handshake.
|
||||||
|
func handshake(c *websocket.Config, req *http.Request) error {
|
||||||
|
o, err := websocket.Origin(c, req)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("bad websocket origin:", err)
|
||||||
|
return websocket.ErrBadWebSocketOrigin
|
||||||
|
}
|
||||||
|
ok := c.Origin.Scheme == o.Scheme && c.Origin.Host == o.Host
|
||||||
|
if !ok {
|
||||||
|
log.Println("bad websocket origin:", o)
|
||||||
|
return websocket.ErrBadWebSocketOrigin
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// socketHandler handles the websocket connection for a given present session.
|
// socketHandler handles the websocket connection for a given present session.
|
||||||
// It handles transcoding Messages to and from JSON format, and starting
|
// It handles transcoding Messages to and from JSON format, and starting
|
||||||
// and killing processes.
|
// and killing processes.
|
||||||
|
|
Loading…
Reference in New Issue