diff --git a/core/hits.go b/core/hits.go
index 409cf8a5..67d5d5f2 100644
--- a/core/hits.go
+++ b/core/hits.go
@@ -67,7 +67,7 @@ func (s *Service) SelectHitsGroupBy(group string) ([]*types.Hit, error) {
return hits, err.Error
}
-// TotalHits returns the total amount of successfull hits a service has
+// TotalHits returns the total amount of successful hits a service has
func (s *Service) TotalHits() (uint64, error) {
var count uint64
col := hitsDB().Where("service = ?", s.Id)
diff --git a/handlers/routes.go b/handlers/routes.go
index f46aa8ec..2b3927f5 100644
--- a/handlers/routes.go
+++ b/handlers/routes.go
@@ -51,7 +51,19 @@ func Router() *mux.Router {
r.Handle("/charts/{id}.js", http.HandlerFunc(RenderServiceChartHandler))
r.Handle("/setup", http.HandlerFunc(SetupHandler)).Methods("GET")
r.Handle("/setup", http.HandlerFunc(ProcessSetupHandler)).Methods("POST")
- r.Handle("/dashboard", http.HandlerFunc(DashboardHandler)).Methods("GET").HandlerFunc(UsersHandler).Methods("GET")
+ r.Handle("/dashboard", http.HandlerFunc(DashboardHandler)).Methods("GET")
+ r.Handle("/dashboard", http.HandlerFunc(LoginHandler)).Methods("POST")
+ r.Handle("/logout", http.HandlerFunc(LogoutHandler))
+ r.Handle("/services", http.HandlerFunc(ServicesHandler)).Methods("GET")
+ r.Handle("/services", http.HandlerFunc(CreateServiceHandler)).Methods("POST")
+ r.Handle("/services/reorder", http.HandlerFunc(ReorderServiceHandler)).Methods("POST")
+ r.Handle("/service/{id}", http.HandlerFunc(ServicesViewHandler)).Methods("GET")
+ r.Handle("/service/{id}", http.HandlerFunc(ServicesUpdateHandler)).Methods("POST")
+ r.Handle("/service/{id}/edit", http.HandlerFunc(ServicesViewHandler))
+ r.Handle("/service/{id}/delete", http.HandlerFunc(ServicesDeleteHandler))
+ r.Handle("/service/{id}/delete_failures", http.HandlerFunc(ServicesDeleteFailuresHandler)).Methods("GET")
+ r.Handle("/service/{id}/checkin", http.HandlerFunc(CheckinCreateUpdateHandler)).Methods("POST")
+ r.Handle("/users", http.HandlerFunc(UsersHandler)).Methods("GET")
r.Handle("/users", http.HandlerFunc(CreateUserHandler)).Methods("POST")
r.Handle("/user/{id}", http.HandlerFunc(UsersEditHandler)).Methods("GET")
r.Handle("/user/{id}", http.HandlerFunc(UpdateUserHandler)).Methods("POST")
diff --git a/notifiers/discord.go b/notifiers/discord.go
index dadda8da..a0542efd 100644
--- a/notifiers/discord.go
+++ b/notifiers/discord.go
@@ -57,6 +57,7 @@ func init() {
}
}
+// Send will send a HTTP Post to the Discord API. It accepts type: []byte
func (u *Discord) Send(msg interface{}) error {
message := msg.([]byte)
req, _ := http.NewRequest("POST", discorder.GetValue("host"), bytes.NewBuffer(message))
@@ -73,15 +74,18 @@ func (u *Discord) Select() *notifier.Notification {
return u.Notification
}
+// OnFailure will trigger failing service
func (u *Discord) OnFailure(s *types.Service, f *types.Failure) {
msg := fmt.Sprintf(`{"content": "Your service '%v' is currently failing! Reason: %v"}`, s.Name, f.Issue)
u.AddQueue(msg)
}
+// OnSuccess will trigger successful service
func (u *Discord) OnSuccess(s *types.Service) {
}
+// OnSave triggers when this notifier has been saved
func (u *Discord) OnSave() error {
msg := fmt.Sprintf(`{"content": "The Discord notifier on Statup was just updated."}`)
u.AddQueue(msg)
diff --git a/notifiers/email.go b/notifiers/email.go
index 50b1b482..3773810a 100644
--- a/notifiers/email.go
+++ b/notifiers/email.go
@@ -85,6 +85,7 @@ func init() {
}
}
+// Send will send the SMTP email with your authentication It accepts type: *EmailOutgoing
func (u *Email) Send(msg interface{}) error {
email := msg.(*EmailOutgoing)
err := u.dialSend(email)
@@ -117,7 +118,7 @@ type EmailOutgoing struct {
Sent bool
}
-// ON SERVICE FAILURE, DO YOUR OWN FUNCTIONS
+// OnFailure will trigger failing service
func (u *Email) OnFailure(s *types.Service, f *types.Failure) {
email := &EmailOutgoing{
To: emailer.GetValue("var2"),
@@ -129,7 +130,7 @@ func (u *Email) OnFailure(s *types.Service, f *types.Failure) {
u.AddQueue(email)
}
-// ON SERVICE SUCCESS, DO YOUR OWN FUNCTIONS
+// OnSuccess will trigger successful service
func (u *Email) OnSuccess(s *types.Service) {
}
@@ -138,7 +139,7 @@ func (u *Email) Select() *notifier.Notification {
return u.Notification
}
-// ON SAVE OR UPDATE OF THE NOTIFIER FORM
+// OnSave triggers when this notifier has been saved
func (u *Email) OnSave() error {
utils.Log(1, fmt.Sprintf("Notification %v is receiving updated information.", u.Method))
// Do updating stuff here
diff --git a/notifiers/line_notify.go b/notifiers/line_notify.go
index e25374e9..160c31b1 100644
--- a/notifiers/line_notify.go
+++ b/notifiers/line_notify.go
@@ -55,6 +55,7 @@ func init() {
}
}
+// Send will send a HTTP Post with the Authorization to the notify-api.line.me server. It accepts type: string
func (u *LineNotify) Send(msg interface{}) error {
message := msg.(string)
client := new(http.Client)
@@ -75,18 +76,18 @@ func (u *LineNotify) Select() *notifier.Notification {
return u.Notification
}
-// ON SERVICE FAILURE, DO YOUR OWN FUNCTIONS
+// OnFailure will trigger failing service
func (u *LineNotify) OnFailure(s *types.Service, f *types.Failure) {
msg := fmt.Sprintf("Your service '%v' is currently offline!", s.Name)
u.AddQueue(msg)
}
-// ON SERVICE SUCCESS, DO YOUR OWN FUNCTIONS
+// OnSuccess will trigger successful service
func (u *LineNotify) OnSuccess(s *types.Service) {
}
-// ON SAVE OR UPDATE OF THE NOTIFIER FORM
+// OnSave triggers when this notifier has been saved
func (u *LineNotify) OnSave() error {
utils.Log(1, fmt.Sprintf("Notification %v is receiving updated information.", u.Method))
// Do updating stuff here
diff --git a/notifiers/slack.go b/notifiers/slack.go
index ba8097a2..7ae2fb7a 100644
--- a/notifiers/slack.go
+++ b/notifiers/slack.go
@@ -81,6 +81,7 @@ func init() {
}
}
+// Send will send a HTTP Post to the Slack Webhook API. It accepts type: string
func (u *Slack) Send(msg interface{}) error {
message := msg.(string)
client := new(http.Client)
@@ -105,7 +106,7 @@ func (u *Slack) OnTest(n notifier.Notification) (bool, error) {
return true, err
}
-// ON SERVICE FAILURE, DO YOUR OWN FUNCTIONS
+// OnFailure will trigger failing service
func (u *Slack) OnFailure(s *types.Service, f *types.Failure) {
message := SlackMessage{
Service: s,
@@ -115,12 +116,12 @@ func (u *Slack) OnFailure(s *types.Service, f *types.Failure) {
parseSlackMessage(FAILING_TEMPLATE, message)
}
-// ON SERVICE SUCCESS, DO YOUR OWN FUNCTIONS
+// OnSuccess will trigger successful service
func (u *Slack) OnSuccess(s *types.Service) {
}
-// ON SAVE OR UPDATE OF THE NOTIFIER FORM
+// OnSave triggers when this notifier has been saved
func (u *Slack) OnSave() error {
message := fmt.Sprintf("Notification %v is receiving updated information.", u.Method)
u.AddQueue(message)
diff --git a/notifiers/twilio.go b/notifiers/twilio.go
index 141228ce..676d0c59 100644
--- a/notifiers/twilio.go
+++ b/notifiers/twilio.go
@@ -30,29 +30,29 @@ import (
)
const (
- TWILIO_METHOD = "twilio"
+ twilioMethod = "twilioNotifier"
)
-type Twilio struct {
+type twilio struct {
*notifier.Notification
}
-var twilio = &Twilio{¬ifier.Notification{
- Method: TWILIO_METHOD,
- Title: "Twilio",
- Description: "Receive SMS text messages directly to your cellphone when a service is offline. You can use a Twilio test account with limits. This notifier uses the Twilio API.",
+var twilioNotifier = &twilio{¬ifier.Notification{
+ Method: twilioMethod,
+ Title: "twilioNotifier",
+ Description: "Receive SMS text messages directly to your cellphone when a service is offline. You can use a twilioNotifier test account with limits. This notifier uses the twilioNotifier API.",
Author: "Hunter Long",
AuthorUrl: "https://github.com/hunterlong",
Delay: time.Duration(10 * time.Second),
Form: []notifier.NotificationForm{{
Type: "text",
Title: "Account Sid",
- Placeholder: "Insert your Twilio Account Sid",
+ Placeholder: "Insert your twilioNotifier Account Sid",
DbField: "api_key",
}, {
Type: "text",
Title: "Account Token",
- Placeholder: "Insert your Twilio Account Token",
+ Placeholder: "Insert your twilioNotifier Account Token",
DbField: "api_secret",
}, {
Type: "text",
@@ -69,19 +69,20 @@ var twilio = &Twilio{¬ifier.Notification{
// DEFINE YOUR NOTIFICATION HERE.
func init() {
- err := notifier.AddNotifier(twilio)
+ err := notifier.AddNotifier(twilioNotifier)
if err != nil {
panic(err)
}
}
-func (u *Twilio) Select() *notifier.Notification {
+func (u *twilio) Select() *notifier.Notification {
return u.Notification
}
-func (u *Twilio) Send(msg interface{}) error {
+// Send will send a HTTP Post to the Twilio SMS API. It accepts type: string
+func (u *twilio) Send(msg interface{}) error {
message := msg.(string)
- twilioUrl := fmt.Sprintf("https://api.twilio.com/2010-04-01/Accounts/%v/Messages.json", u.GetValue("api_key"))
+ twilioUrl := fmt.Sprintf("https://api.twilioNotifier.com/2010-04-01/Accounts/%v/Messages.json", u.GetValue("api_key"))
client := &http.Client{}
v := url.Values{}
v.Set("To", "+"+u.Var1)
@@ -100,24 +101,24 @@ func (u *Twilio) Send(msg interface{}) error {
contents, _ := ioutil.ReadAll(res.Body)
success, twilioRes := twilioSuccess(contents)
if !success {
- return errors.New(fmt.Sprintf("twilio didn't receive the expected status of 'enque' from API got: %v", twilioRes))
+ return errors.New(fmt.Sprintf("twilioNotifier didn't receive the expected status of 'enque' from API got: %v", twilioRes))
}
return nil
}
-// ON SERVICE FAILURE, DO YOUR OWN FUNCTIONS
-func (u *Twilio) OnFailure(s *types.Service, f *types.Failure) {
+// OnFailure will trigger failing service
+func (u *twilio) OnFailure(s *types.Service, f *types.Failure) {
msg := fmt.Sprintf("Your service '%v' is currently offline!", s.Name)
u.AddQueue(msg)
}
-// ON SERVICE SUCCESS, DO YOUR OWN FUNCTIONS
-func (u *Twilio) OnSuccess(s *types.Service) {
+// OnSuccess will trigger successful service
+func (u *twilio) OnSuccess(s *types.Service) {
}
-// ON SAVE OR UPDATE OF THE NOTIFIER FORM
-func (u *Twilio) OnSave() error {
+// OnSave triggers when this notifier has been saved
+func (u *twilio) OnSave() error {
utils.Log(1, fmt.Sprintf("Notification %v is receiving updated information.", u.Method))
// Do updating stuff here
diff --git a/notifiers/twilio_test.go b/notifiers/twilio_test.go
index 8736e911..9a13554b 100644
--- a/notifiers/twilio_test.go
+++ b/notifiers/twilio_test.go
@@ -13,54 +13,54 @@ var (
TWILIO_SECRET = os.Getenv("TWILIO_SECRET")
TWILIO_FROM = os.Getenv("TWILIO_FROM")
TWILIO_TO = os.Getenv("TWILIO_TO")
- twilioMessage = "The Twilio notifier on Statup has been tested!"
+ twilioMessage = "The twilioNotifier notifier on Statup has been tested!"
)
func init() {
- twilio.ApiKey = TWILIO_SID
- twilio.ApiSecret = TWILIO_SECRET
- twilio.Var1 = TWILIO_TO
- twilio.Var2 = TWILIO_FROM
+ twilioNotifier.ApiKey = TWILIO_SID
+ twilioNotifier.ApiSecret = TWILIO_SECRET
+ twilioNotifier.Var1 = TWILIO_TO
+ twilioNotifier.Var2 = TWILIO_FROM
}
func TestTwilioNotifier(t *testing.T) {
if TWILIO_SID == "" || TWILIO_SECRET == "" || TWILIO_FROM == "" {
- t.Log("Twilio notifier testing skipped, missing TWILIO_SID environment variable")
+ t.Log("twilioNotifier notifier testing skipped, missing TWILIO_SID environment variable")
t.SkipNow()
}
currentCount = CountNotifiers()
- t.Run("Load Twilio", func(t *testing.T) {
- twilio.ApiKey = TWILIO_SID
- twilio.Delay = time.Duration(100 * time.Millisecond)
- err := notifier.AddNotifier(twilio)
+ t.Run("Load twilioNotifier", func(t *testing.T) {
+ twilioNotifier.ApiKey = TWILIO_SID
+ twilioNotifier.Delay = time.Duration(100 * time.Millisecond)
+ err := notifier.AddNotifier(twilioNotifier)
assert.Nil(t, err)
- assert.Equal(t, "Hunter Long", twilio.Author)
- assert.Equal(t, TWILIO_SID, twilio.ApiKey)
+ assert.Equal(t, "Hunter Long", twilioNotifier.Author)
+ assert.Equal(t, TWILIO_SID, twilioNotifier.ApiKey)
assert.Equal(t, currentCount+1, CountNotifiers())
})
- t.Run("Load Twilio Notifier", func(t *testing.T) {
+ t.Run("Load twilioNotifier Notifier", func(t *testing.T) {
count := notifier.Load()
assert.Equal(t, currentCount+1, len(count))
})
- t.Run("Twilio Within Limits", func(t *testing.T) {
- ok, err := twilio.WithinLimits()
+ t.Run("twilioNotifier Within Limits", func(t *testing.T) {
+ ok, err := twilioNotifier.WithinLimits()
assert.Nil(t, err)
assert.True(t, ok)
})
- t.Run("Twilio Send", func(t *testing.T) {
- err := twilio.Send(twilioMessage)
+ t.Run("twilioNotifier Send", func(t *testing.T) {
+ err := twilioNotifier.Send(twilioMessage)
assert.Nil(t, err)
})
- t.Run("Twilio Queue", func(t *testing.T) {
- go notifier.Queue(twilio)
+ t.Run("twilioNotifier Queue", func(t *testing.T) {
+ go notifier.Queue(twilioNotifier)
time.Sleep(1 * time.Second)
- assert.Equal(t, TWILIO_SID, twilio.ApiKey)
- assert.Equal(t, 0, len(twilio.Queue))
+ assert.Equal(t, TWILIO_SID, twilioNotifier.ApiKey)
+ assert.Equal(t, 0, len(twilioNotifier.Queue))
})
}