-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/liwss/rulex into dev-http…
…_server
- Loading branch information
Showing
2 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,45 @@ | ||
package server | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
"github.com/hootrhino/rulex/typex" | ||
) | ||
|
||
/* | ||
* | ||
* API Server | ||
* | ||
*/ | ||
type RulexApiServer struct { | ||
ginEngine *gin.Engine | ||
ruleEngine typex.RuleX | ||
} | ||
|
||
/* | ||
* | ||
* 新建路由 | ||
* | ||
*/ | ||
func (ras *RulexApiServer) AddRoute(method, path string, handler func(ctx *gin.Context)) { | ||
if method == "GET" { | ||
ras.ginEngine.GET(path, handler) | ||
} | ||
if method == "POST" { | ||
ras.ginEngine.POST(path, handler) | ||
} | ||
if method == "PUT" { | ||
ras.ginEngine.PUT(path, handler) | ||
} | ||
if method == "DELETE" { | ||
ras.ginEngine.DELETE(path, handler) | ||
} | ||
} | ||
|
||
/* | ||
* | ||
* API 调用 | ||
* | ||
*/ | ||
func (ras *RulexApiServer) InvokeAPI(name string) { | ||
|
||
} |