Refactor application into multiple files
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package rest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func setupHTTPServer(data_dir string) {
|
||||
http.HandleFunc("/get_episodes", func(w http.ResponseWriter, r *http.Request) {
|
||||
getEpisodesHandler(data_dir, w, r)
|
||||
})
|
||||
http.HandleFunc("/get_shows", func(w http.ResponseWriter, r *http.Request) {
|
||||
getShowsHandler(data_dir, w, r)
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
func RunHTTPServer(address string, port int, data_dir string) {
|
||||
|
||||
setupHTTPServer(data_dir)
|
||||
|
||||
connect_string := fmt.Sprintf("%v:%v", address, port)
|
||||
log.Noticef("Launching HTTP server on %v\n", connect_string)
|
||||
log.Fatal(http.ListenAndServe(connect_string, nil))
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user