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 {
|
||||
file, err := os.Open("./subscription.json")
|
||||
if err != nil {
|
||||
if err != nil && os.IsExist(err) {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
@ -161,6 +161,7 @@ func (handler *subscriptionHandler) save() error {
|
|||
|
||||
func main() {
|
||||
handler := &subscriptionHandler{}
|
||||
handler.Subscribers = make(map[string]Subscriber)
|
||||
handler.load()
|
||||
http.Handle("/", handler)
|
||||
log.Fatal(http.ListenAndServe(":80", nil))
|
||||
|
|
Loading…
Reference in New Issue
Block a user