Move deps from _workspace/ to vendor/
godep restore pushd $GOPATH/src/github.com/appc/spec git co master popd go get go4.org/errorutil rm -rf Godeps godep save ./... git add vendor git add -f $(git ls-files --other vendor/) git co -- Godeps/LICENSES Godeps/.license_file_state Godeps/OWNERS
This commit is contained in:
35
vendor/github.com/emicklei/go-restful/examples/restful-html-template.go
generated
vendored
Normal file
35
vendor/github.com/emicklei/go-restful/examples/restful-html-template.go
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"text/template"
|
||||
|
||||
"github.com/emicklei/go-restful"
|
||||
)
|
||||
|
||||
// This example shows how to serve a HTML page using the standard Go template engine.
|
||||
//
|
||||
// GET http://localhost:8080/
|
||||
|
||||
func main() {
|
||||
ws := new(restful.WebService)
|
||||
ws.Route(ws.GET("/").To(home))
|
||||
restful.Add(ws)
|
||||
print("open browser on http://localhost:8080/\n")
|
||||
http.ListenAndServe(":8080", nil)
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
Text string
|
||||
}
|
||||
|
||||
func home(req *restful.Request, resp *restful.Response) {
|
||||
p := &Message{"restful-html-template demo"}
|
||||
// you might want to cache compiled templates
|
||||
t, err := template.ParseFiles("home.html")
|
||||
if err != nil {
|
||||
log.Fatalf("Template gave: %s", err)
|
||||
}
|
||||
t.Execute(resp.ResponseWriter, p)
|
||||
}
|
||||
Reference in New Issue
Block a user