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