尝试判断methid
This commit is contained in:
@@ -8,7 +8,7 @@ RouterCaseSensitive = false
|
|||||||
filelinenum = true
|
filelinenum = true
|
||||||
|
|
||||||
routinePoolSize = 1000
|
routinePoolSize = 1000
|
||||||
|
dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true"
|
||||||
[api]
|
[api]
|
||||||
httpport = 8889
|
httpport = 8889
|
||||||
EnableDocs = true
|
EnableDocs = true
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/astaxie/beego/server/web"
|
"github.com/astaxie/beego/server/web"
|
||||||
"reflect"
|
"reflect"
|
||||||
)
|
)
|
||||||
@@ -20,6 +21,7 @@ func Init() {
|
|||||||
vft := vf.Type()
|
vft := vf.Type()
|
||||||
//读取方法数量
|
//读取方法数量
|
||||||
mNum := vf.NumMethod()
|
mNum := vf.NumMethod()
|
||||||
|
fmt.Println("mNum", mNum)
|
||||||
//遍历路由器的方法,并将其存入控制器映射变量中
|
//遍历路由器的方法,并将其存入控制器映射变量中
|
||||||
for i := 0; i < mNum; i++ {
|
for i := 0; i < mNum; i++ {
|
||||||
mName := vft.Method(i).Name
|
mName := vft.Method(i).Name
|
||||||
@@ -37,5 +39,13 @@ func Init() {
|
|||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /CallOpenAPI [post]
|
// @router /CallOpenAPI [post]
|
||||||
func (c *ApiController) CallOpenAPI() {
|
func (c *ApiController) CallOpenAPI() {
|
||||||
|
fmt.Println(routerMap)
|
||||||
|
method := c.GetString("method")
|
||||||
|
parms := []reflect.Value{reflect.ValueOf("test")}
|
||||||
|
|
||||||
|
fmt.Println("routerMap[method].Call(parms)", routerMap[method].Call(parms))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ApiController) AddPrint() {
|
||||||
|
fmt.Println("call AddPrint success ...")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user