2015-01-18 16:31:22 -05:00
|
|
|
package httpserver
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Start(handler http.Handler) (chan<- string, <-chan error) {
|
|
|
|
ctrlChannel := make(chan string)
|
|
|
|
errorChannel := make(chan error)
|
|
|
|
go start(ctrlChannel, errorChannel, handler)
|
|
|
|
return ctrlChannel, errorChannel
|
|
|
|
}
|
|
|
|
|
|
|
|
func start(ctrlChannel <-chan string, errorChannel chan<- error, router http.Handler) {
|
|
|
|
log.Println("Starting HTTP Server")
|
|
|
|
err := http.ListenAndServe(":8080", router)
|
|
|
|
errorChannel <- err
|
2015-01-18 19:59:23 -05:00
|
|
|
close(errorChannel)
|
2015-01-18 16:31:22 -05:00
|
|
|
}
|