Kaynağa Gözat

changed the endpoint

Alan Yeung 2 yıl önce
ebeveyn
işleme
1dd379b89a
3 değiştirilmiş dosya ile 5 ekleme ve 13 silme
  1. 0 10
      lambda.json
  2. 1 1
      main.router.go
  3. 4 2
      mod/agi/external.agi.go

+ 0 - 10
lambda.json

@@ -1,10 +0,0 @@
-{
-    "uuid1": {
-      "username": "admin",
-      "path": "user:/test.agi"
-    },
-    "uuid2": {
-        "username": "admin",
-        "path": "user:/test1.agi"
-      }
-  }

+ 1 - 1
main.router.go

@@ -69,7 +69,7 @@ func mrouter(h http.Handler) http.Handler {
 			WebDavHandler.HandleRequest(w, r)
 		} else if len(r.URL.Path) >= len("/share") && r.URL.Path[:6] == "/share" {
 			shareManager.HandleShareAccess(w, r)
-		} else if len(r.URL.Path) >= len("/rexec") && r.URL.Path[:6] == "/rexec" {
+		} else if len(r.URL.Path) >= len("/api/remote") && r.URL.Path[:11] == "/api/remote" {
 			AGIGateway.ExtAPIHandler(w, r)
 		} else if r.URL.Path == "/" && authAgent.CheckAuth(r) {
 			//Use logged in and request the index. Serve the user's interface module

+ 4 - 2
mod/agi/external.agi.go

@@ -34,14 +34,14 @@ func (g *Gateway) ExtAPIHandler(w http.ResponseWriter, r *http.Request) {
 	subpathElements := strings.Split(requestURI[1:], "/")
 
 	// check if it contains only two part, [rexec uuid]
-	if len(subpathElements) != 2 {
+	if len(subpathElements) != 3 {
 		common.SendErrorResponse(w, "Bad Request, invaild request sent")
 		return
 	}
 
 	// check if UUID exists in the database
 	// get the info from the database
-	data, isExist := g.checkIfExternalEndpointExist(subpathElements[1])
+	data, isExist := g.checkIfExternalEndpointExist(subpathElements[2])
 	if !isExist {
 		common.SendErrorResponse(w, "Bad Request, invaild UUID entered")
 		return
@@ -98,6 +98,8 @@ func (g *Gateway) AddExternalEndPoint(w http.ResponseWriter, r *http.Request) {
 	jsonStr, _ := json.Marshal(dat)
 
 	sysdb.Write("external_agi", id, string(jsonStr))
+
+	sendOK(w)
 }
 
 func (g *Gateway) RemoveExternalEndPoint(w http.ResponseWriter, r *http.Request) {