ソースを参照

Update agi.go

Alan Yeung 2 年 前
コミット
c837b1509a
1 ファイル変更13 行追加4 行削除
  1. 13 4
      agi.go

+ 13 - 4
agi.go

@@ -5,6 +5,7 @@ import (
 
 	agi "imuslab.com/arozos/mod/agi"
 	"imuslab.com/arozos/mod/common"
+	prout "imuslab.com/arozos/mod/prouter"
 )
 
 var (
@@ -74,10 +75,18 @@ func AGIInit() {
 
 	http.HandleFunc("/api/ajgi/exec", gw.HandleAgiExecutionRequestWithToken)
 
-	// external AGI related functions
-	http.HandleFunc("/api/ajgi/listExt", gw.ListExternalEndpoint)
-	http.HandleFunc("/api/ajgi/addExt", gw.AddExternalEndPoint)
-	http.HandleFunc("/api/ajgi/rmExt", gw.RemoveExternalEndPoint)
+	// external AGI related function
+	externalAGIRouter := prout.NewModuleRouter(prout.RouterOption{
+		ModuleName:  "External AGI",
+		AdminOnly:   false,
+		UserHandler: userHandler,
+		DeniedHandler: func(w http.ResponseWriter, r *http.Request) {
+			errorHandlePermissionDenied(w, r)
+		},
+	})
+	externalAGIRouter.HandleFunc("/api/ajgi/listExt", gw.ListExternalEndpoint)
+	externalAGIRouter.HandleFunc("/api/ajgi/addExt", gw.AddExternalEndPoint)
+	externalAGIRouter.HandleFunc("/api/ajgi/rmExt", gw.RemoveExternalEndPoint)
 
 	AGIGateway = gw
 }