diff --git a/examples/board/main.go b/examples/board/main.go index 570ae1c..44bf1de 100644 --- a/examples/board/main.go +++ b/examples/board/main.go @@ -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 { diff --git a/examples/gifs/main.go b/examples/gifs/main.go index c91e51c..6138fb1 100644 --- a/examples/gifs/main.go +++ b/examples/gifs/main.go @@ -12,7 +12,7 @@ func main () { http.HandleFunc("/gifs/", gifs) http.Handle("/gifs/static/", http.StripPrefix("/gifs/static", static)) - err := (&service.HTTP { Mount: service.Mount { + err := (&service.HTTP { Mount: service.MountConfig { Path: "/gifs/", Name: "Gifs", Description: "Serves a lot of big gifs on one page.", diff --git a/examples/hellorld/main.go b/examples/hellorld/main.go index c466cc2..fc40c82 100644 --- a/examples/hellorld/main.go +++ b/examples/hellorld/main.go @@ -7,7 +7,7 @@ import "hnakra/service" func main () { http.HandleFunc("/hello/", hellorld) - err := (&service.HTTP { Mount: service.Mount { + err := (&service.HTTP { Mount: service.MountConfig { Path: "/hello/", Name: "Hellorld", Description: "A test service.", diff --git a/examples/kamikaze/main.go b/examples/kamikaze/main.go index b6248f3..493ab07 100644 --- a/examples/kamikaze/main.go +++ b/examples/kamikaze/main.go @@ -7,7 +7,7 @@ import "hnakra/service" func main () { http.HandleFunc("/kamikaze/", hellorld) - err := (&service.HTTP { Mount: service.Mount { + err := (&service.HTTP { Mount: service.MountConfig { Path: "/kamikaze/", Name: "Kamikaze", Description: "A service that abrupltly closes upon any request, for testing", diff --git a/routines/routines.go b/routines/routines.go index f39c3f2..9acc12d 100644 --- a/routines/routines.go +++ b/routines/routines.go @@ -38,6 +38,7 @@ func (manager *Manager) Run () error { for _, routine := range manager.Routines { if routine != nil { + println("yeah") waitGroup.Add(1) go manager.runRoutine(routine, &waitGroup, &errExit) } diff --git a/service/service.go b/service/service.go index edc7ce2..f246bef 100644 --- a/service/service.go +++ b/service/service.go @@ -26,8 +26,8 @@ func (service Service) Run () error { // set up routine manager manager := routines.Manager { RestartDeadline: time.Second * 8 } manager.Routines = make([]routines.Routine, len(service)) - for index, mount := range manager.Routines { - manager.Routines[index] = mount + for index, mount := range service { + manager.Routines[index] = mount.Run } // send it