Fix map, don't kill app when file doesnt exist
This commit is contained in:
parent
6a696e3a68
commit
a3f4c4fbac
|
|
@ -138,7 +138,7 @@ func (handler *subscriptionHandler) ServeHTTP(w http.ResponseWriter, r *http.Req
|
||||||
|
|
||||||
func (handler *subscriptionHandler) load() error {
|
func (handler *subscriptionHandler) load() error {
|
||||||
file, err := os.Open("./subscription.json")
|
file, err := os.Open("./subscription.json")
|
||||||
if err != nil {
|
if err != nil && os.IsExist(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
@ -161,6 +161,7 @@ func (handler *subscriptionHandler) save() error {
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
handler := &subscriptionHandler{}
|
handler := &subscriptionHandler{}
|
||||||
|
handler.Subscribers = make(map[string]Subscriber)
|
||||||
handler.load()
|
handler.load()
|
||||||
http.Handle("/", handler)
|
http.Handle("/", handler)
|
||||||
log.Fatal(http.ListenAndServe(":80", nil))
|
log.Fatal(http.ListenAndServe(":80", nil))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user