Update examples to match
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package main
|
||||
|
||||
import "log"
|
||||
import "sync"
|
||||
import "path"
|
||||
import "net/http"
|
||||
@@ -14,8 +13,9 @@ type Post struct {
|
||||
}
|
||||
|
||||
type Board struct {
|
||||
service.Service
|
||||
|
||||
root string
|
||||
mount *service.HTTP
|
||||
mux *http.ServeMux
|
||||
template *template.Template
|
||||
|
||||
@@ -26,14 +26,16 @@ type Board struct {
|
||||
func main () {
|
||||
board := Board { root: "/board/" }
|
||||
board.mux = http.NewServeMux()
|
||||
board.mount = &service.HTTP {
|
||||
Mount: service.Mount {
|
||||
Path: board.root,
|
||||
Name: "Board",
|
||||
Description: "A board where you can post things.",
|
||||
TLSConfig: &tls.Config { InsecureSkipVerify: true },
|
||||
board.Service = service.Service {
|
||||
&service.HTTP {
|
||||
Mount: service.MountConfig {
|
||||
Path: board.root,
|
||||
Name: "Board",
|
||||
Description: "A board where you can post things.",
|
||||
TLSConfig: &tls.Config { InsecureSkipVerify: true },
|
||||
},
|
||||
Handler: board.mux,
|
||||
},
|
||||
Handler: board.mux,
|
||||
}
|
||||
handle := func (pattern string, handler func (http.ResponseWriter, *http.Request)) {
|
||||
board.mux.HandleFunc(pattern, handler)
|
||||
@@ -42,10 +44,7 @@ func main () {
|
||||
handle(path.Join(board.root, "actionPost"), board.serveActionPost)
|
||||
board.template = template.Must(template.New("board").Parse(tem))
|
||||
|
||||
err := board.mount.Run()
|
||||
if err != nil {
|
||||
log.Println("XXX", err)
|
||||
}
|
||||
board.Run()
|
||||
}
|
||||
|
||||
func (board *Board) getPosts (max int) []*Post {
|
||||
|
||||
Reference in New Issue
Block a user