From e7064184ef1f4b2ae4cc4f90b707510bdf0a54e5 Mon Sep 17 00:00:00 2001 From: thomasgouveia Date: Tue, 25 Apr 2023 21:32:32 +0200 Subject: [PATCH] refactor: remove deprecated example Signed-off-by: thomasgouveia --- message-to-discord/go.mod | 3 --- message-to-discord/handler.go | 35 ----------------------------------- message-to-discord/morty.yaml | 2 -- 3 files changed, 40 deletions(-) delete mode 100644 message-to-discord/go.mod delete mode 100644 message-to-discord/handler.go delete mode 100644 message-to-discord/morty.yaml diff --git a/message-to-discord/go.mod b/message-to-discord/go.mod deleted file mode 100644 index 2213749..0000000 --- a/message-to-discord/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module handler/function - -go 1.19 diff --git a/message-to-discord/handler.go b/message-to-discord/handler.go deleted file mode 100644 index ab10add..0000000 --- a/message-to-discord/handler.go +++ /dev/null @@ -1,35 +0,0 @@ -package function - -import ( - "bytes" - "encoding/json" - "fmt" - "net/http" -) - -const ( - webhookUrl = "https://discord.com/api/webhooks/1089563947423764550/LuUfqOQMwscSZlS9gOboRraau0J-rJw9YCMKJ03RA2P5q1GKOGQUUB8Ezqlr1G4T3EIz" -) - -func Handler(w http.ResponseWriter, r *http.Request) { - if r.Method != http.MethodPost { - http.Error(w, "This function accept only POST requests", http.StatusMethodNotAllowed) - return - } - - //TODO: get message from request - data, _ := json.Marshal(map[string]interface{}{ - "user": "Morty", - "content": "Hello from a Morty function !", - }) - - req, _ := http.NewRequest(http.MethodPost, webhookUrl, bytes.NewReader(data)) - req.Header.Add("Content-Type", "application/json") - - if _, err := http.DefaultClient.Do(req); err != nil { - http.Error(w, fmt.Sprintf("failed to send data to webhook: %v", err), http.StatusInternalServerError) - return - } - - w.WriteHeader(http.StatusNoContent) -} diff --git a/message-to-discord/morty.yaml b/message-to-discord/morty.yaml deleted file mode 100644 index dff9312..0000000 --- a/message-to-discord/morty.yaml +++ /dev/null @@ -1,2 +0,0 @@ -name: message-to-discord -runtime: go-1.19