Skip to content

Instantly share code, notes, and snippets.

@buildingwatsize
Created July 20, 2020 09:13
Show Gist options
  • Save buildingwatsize/f5c53406926fc963cec8ec514216bdce to your computer and use it in GitHub Desktop.
Save buildingwatsize/f5c53406926fc963cec8ec514216bdce to your computer and use it in GitHub Desktop.
api.go - Goldnoti [Phase 2]
// GetTodayPriceForLINEBot : Get today gold price with webhook
func GetTodayPriceForLINEBot(w http.ResponseWriter, r *http.Request) {
log.Println("------- API: GetTodayPriceForLINEBot -------")
defer r.Body.Close()
w.Header().Set(contentTypeKey, contentTypeValue)
if !isPOST(r) {
ResponseMethodNotAllowed(w)
return
}
events, err := repository.Bot.ParseRequest(r)
if err != nil {
if err == linebot.ErrInvalidSignature {
ResponseBadRequest(w)
} else {
ResponseInternalServerError(w)
}
return
}
for _, event := range events {
if event.Type == linebot.EventTypeMessage {
go service.HandleLINEEventMessage(event)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment