You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by GitBox <gi...@apache.org> on 2022/12/07 10:54:52 UTC

[GitHub] [incubator-eventmesh] github-code-scanning[bot] commented on a diff in pull request #2499: Eventmesh server go

github-code-scanning[bot] commented on code in PR #2499:
URL: https://github.com/apache/incubator-eventmesh/pull/2499#discussion_r1042058572


##########
eventmesh-server-go/examples/webhook/main.go:
##########
@@ -0,0 +1,79 @@
+// Copyright (C) @2021 Webank Group Holding Limited
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+// in compliance with the License. You may obtain a copy of the License at
+//
+// 	http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software distributed under the License
+// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+// or implied. See the License for the specific language governing permissions and limitations under
+// the License.
+// date: 2021/03/07 15:45
+// author: bruceliu@webank.com
+
+package main
+
+import (
+	"flag"
+	"fmt"
+	"github.com/gin-gonic/gin"
+	"io/ioutil"
+	"net/http"
+	"net/url"
+	"strings"
+)
+
+// Response indicate the http response
+type Response struct {
+	RetCode string `json:"retCode"`
+	ErrMsg  string `json:"errMsg"`
+}
+
+// OK return the success response
+func OK(data interface{}) *Response {
+	return &Response{
+		RetCode: "0",
+		ErrMsg:  "OK",
+	}
+}
+
+// Err return the error response
+func Err(err error, code string) *Response {
+	return &Response{
+		RetCode: code,
+		ErrMsg:  err.Error(),
+	}
+}
+
+// provide a webserver to handle the operator event callback
+func main() {
+	flag.Parse()
+	router := gin.Default()
+	printAndReply := func(c *gin.Context) {
+		buf, err := ioutil.ReadAll(c.Request.Body)
+		if err != nil {
+			c.JSON(http.StatusOK, Err(err, "-1"))
+			return
+		}
+		content, err := url.QueryUnescape(string(buf))
+		if err != nil {
+			c.JSON(http.StatusOK, Err(err, "-1"))
+			return
+		}
+		sps := strings.Split(content, "&")
+		for _, sp := range sps {
+			fmt.Println(sp)

Review Comment:
   ## Log entries created from user input
   
   This log entry depends on a [user-provided value](1).
   
   [Show more details](https://github.com/apache/incubator-eventmesh/security/code-scanning/7)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org