Skip to content

Commit

Permalink
Add support GET request too for CK
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 committed Feb 19, 2018
1 parent 5dd716f commit 6f0c722
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions handlers/chikka/chikka.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ func init() {
// Initialize is called by the engine once everything is loaded
func (h *handler) Initialize(s courier.Server) error {
h.SetServer(s)
err := s.AddHandlerRoute(h, http.MethodGet, "receive", h.ReceiveMessage)
if err != nil {
return err
}

return s.AddHandlerRoute(h, http.MethodPost, "receive", h.ReceiveMessage)
}

Expand Down
4 changes: 4 additions & 0 deletions handlers/chikka/chikka_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ var testCases = []ChannelHandleTestCase{
{Label: "Receive Valid", URL: receiveURL, Data: validReceive, Status: 200, Response: "Message Accepted",
Text: Sp("Hello World"), URN: Sp("tel:+639178020779"), ExternalID: Sp("4004"),
Date: Tp(time.Date(2016, 03, 11, 04, 20, 59, 690000128, time.UTC))},
{Label: "Receive Valid via GET", URL: receiveURL + "?" + validReceive, Status: 200, Response: "Message Accepted",
Text: Sp("Hello World"), URN: Sp("tel:+639178020779"), ExternalID: Sp("4004"),
Date: Tp(time.Date(2016, 03, 11, 04, 20, 59, 690000128, time.UTC))},

{Label: "Ignore Invalid message_type", URL: receiveURL, Data: "message_type=invalid", Status: 200, Response: "unknown message_type request"},
{Label: "Status Sent Valid", URL: receiveURL, Data: validSentStatus, Status: 200, Response: `"status":"S"`},
{Label: "Status Sent Valid via GET", URL: receiveURL + "?" + validSentStatus, Status: 200, Response: `"status":"S"`},
{Label: "Status Failed Valid", URL: receiveURL, Data: validFailedStatus, Status: 200, Response: `"status":"F"`},
{Label: "Status Invalid", URL: receiveURL, Data: invalidStatus, Status: 400, Response: `must be either 'SENT' or 'FAILED'`},
}
Expand Down

0 comments on commit 6f0c722

Please sign in to comment.