Created
July 20, 2020 09:13
-
-
Save buildingwatsize/f5c53406926fc963cec8ec514216bdce to your computer and use it in GitHub Desktop.
api.go - Goldnoti [Phase 2]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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