Compare commits
	
		
			No commits in common. "9025844212e74539eaae90dc6a498705e23defa2" and "3d0a69d5a35a1da6ccfcda2d4d3aae4eabf5c072" have entirely different histories.
		
	
	
		
			9025844212
			...
			3d0a69d5a3
		
	
		
@ -1,5 +1,6 @@
 | 
				
			|||||||
package main
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import "log"
 | 
				
			||||||
import "sync"
 | 
					import "sync"
 | 
				
			||||||
import "path"
 | 
					import "path"
 | 
				
			||||||
import "net/http"
 | 
					import "net/http"
 | 
				
			||||||
@ -13,9 +14,8 @@ type Post struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Board struct {
 | 
					type Board struct {
 | 
				
			||||||
	service.Service
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	root     string
 | 
						root     string
 | 
				
			||||||
 | 
						mount    *service.HTTP
 | 
				
			||||||
	mux      *http.ServeMux
 | 
						mux      *http.ServeMux
 | 
				
			||||||
	template *template.Template
 | 
						template *template.Template
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -26,16 +26,14 @@ type Board struct {
 | 
				
			|||||||
func main () {
 | 
					func main () {
 | 
				
			||||||
	board := Board { root: "/board/" }
 | 
						board := Board { root: "/board/" }
 | 
				
			||||||
	board.mux   = http.NewServeMux()
 | 
						board.mux   = http.NewServeMux()
 | 
				
			||||||
	board.Service = service.Service {
 | 
						board.mount = &service.HTTP {
 | 
				
			||||||
		&service.HTTP {
 | 
							Mount: service.Mount {
 | 
				
			||||||
			Mount: service.MountConfig {
 | 
								Path:        board.root,
 | 
				
			||||||
				Path:        board.root,
 | 
								Name:        "Board",
 | 
				
			||||||
				Name:        "Board",
 | 
								Description: "A board where you can post things.",
 | 
				
			||||||
				Description: "A board where you can post things.",
 | 
								TLSConfig:    &tls.Config { InsecureSkipVerify: true },
 | 
				
			||||||
				TLSConfig:    &tls.Config { InsecureSkipVerify: true },
 | 
					 | 
				
			||||||
			},
 | 
					 | 
				
			||||||
			Handler: board.mux,
 | 
					 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							Handler: board.mux,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	handle := func (pattern string, handler func (http.ResponseWriter, *http.Request)) {
 | 
						handle := func (pattern string, handler func (http.ResponseWriter, *http.Request)) {
 | 
				
			||||||
		board.mux.HandleFunc(pattern, handler)
 | 
							board.mux.HandleFunc(pattern, handler)
 | 
				
			||||||
@ -44,7 +42,10 @@ func main () {
 | 
				
			|||||||
	handle(path.Join(board.root, "actionPost"), board.serveActionPost)
 | 
						handle(path.Join(board.root, "actionPost"), board.serveActionPost)
 | 
				
			||||||
	board.template = template.Must(template.New("board").Parse(tem))
 | 
						board.template = template.Must(template.New("board").Parse(tem))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	board.Run()
 | 
						err := board.mount.Run()
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							log.Println("XXX", err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (board *Board) getPosts (max int) []*Post {
 | 
					func (board *Board) getPosts (max int) []*Post {
 | 
				
			||||||
 | 
				
			|||||||
@ -12,7 +12,7 @@ func main () {
 | 
				
			|||||||
	http.HandleFunc("/gifs/", gifs)
 | 
						http.HandleFunc("/gifs/", gifs)
 | 
				
			||||||
	http.Handle("/gifs/static/", http.StripPrefix("/gifs/static", static))
 | 
						http.Handle("/gifs/static/", http.StripPrefix("/gifs/static", static))
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	err := (&service.HTTP { Mount: service.MountConfig {
 | 
						err := (&service.HTTP { Mount: service.Mount {
 | 
				
			||||||
		Path:        "/gifs/",
 | 
							Path:        "/gifs/",
 | 
				
			||||||
		Name:        "Gifs",
 | 
							Name:        "Gifs",
 | 
				
			||||||
		Description: "Serves a lot of big gifs on one page.",
 | 
							Description: "Serves a lot of big gifs on one page.",
 | 
				
			||||||
 | 
				
			|||||||
@ -7,7 +7,7 @@ import "hnakra/service"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func main () {
 | 
					func main () {
 | 
				
			||||||
	http.HandleFunc("/hello/", hellorld)
 | 
						http.HandleFunc("/hello/", hellorld)
 | 
				
			||||||
	err := (&service.HTTP { Mount: service.MountConfig {
 | 
						err := (&service.HTTP { Mount: service.Mount {
 | 
				
			||||||
		Path:        "/hello/",
 | 
							Path:        "/hello/",
 | 
				
			||||||
		Name:        "Hellorld",
 | 
							Name:        "Hellorld",
 | 
				
			||||||
		Description: "A test service.",
 | 
							Description: "A test service.",
 | 
				
			||||||
 | 
				
			|||||||
@ -7,7 +7,7 @@ import "hnakra/service"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func main () {
 | 
					func main () {
 | 
				
			||||||
	http.HandleFunc("/kamikaze/", hellorld)
 | 
						http.HandleFunc("/kamikaze/", hellorld)
 | 
				
			||||||
	err := (&service.HTTP { Mount: service.MountConfig {
 | 
						err := (&service.HTTP { Mount: service.Mount {
 | 
				
			||||||
		Path:        "/kamikaze/",
 | 
							Path:        "/kamikaze/",
 | 
				
			||||||
		Name:        "Kamikaze",
 | 
							Name:        "Kamikaze",
 | 
				
			||||||
		Description: "A service that abrupltly closes upon any request, for testing",
 | 
							Description: "A service that abrupltly closes upon any request, for testing",
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,3 @@
 | 
				
			|||||||
// Package routines provides utilities for managing long-running goroutines.
 | 
					 | 
				
			||||||
package routines
 | 
					package routines
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import "io"
 | 
					import "io"
 | 
				
			||||||
@ -38,7 +37,6 @@ func (manager *Manager) Run () error {
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	for _, routine := range manager.Routines {
 | 
						for _, routine := range manager.Routines {
 | 
				
			||||||
		if routine != nil {
 | 
							if routine != nil {
 | 
				
			||||||
			println("yeah")
 | 
					 | 
				
			||||||
			waitGroup.Add(1)
 | 
								waitGroup.Add(1)
 | 
				
			||||||
			go manager.runRoutine(routine, &waitGroup, &errExit)
 | 
								go manager.runRoutine(routine, &waitGroup, &errExit)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
				
			|||||||
@ -26,8 +26,8 @@ func (service Service) Run () error {
 | 
				
			|||||||
	// set up routine manager
 | 
						// set up routine manager
 | 
				
			||||||
	manager := routines.Manager { RestartDeadline: time.Second * 8 }
 | 
						manager := routines.Manager { RestartDeadline: time.Second * 8 }
 | 
				
			||||||
	manager.Routines = make([]routines.Routine, len(service))
 | 
						manager.Routines = make([]routines.Routine, len(service))
 | 
				
			||||||
	for index, mount := range service {
 | 
						for index, mount := range manager.Routines {
 | 
				
			||||||
		manager.Routines[index] = mount.Run
 | 
							manager.Routines[index] = mount
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// send it
 | 
						// send it
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user