123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package bus
- import (
- "reflect"
- "github.com/gin-gonic/gin"
- "github.com/yuguorong/go/log"
- )
- type RestAppInfo struct {
- AppID string
- AppSecret string
- }
- type RestApi struct {
- baseBus
- router *gin.Engine
- port int
- mapApp map[string]*RestAppInfo
- }
- func (rest *RestApi) Init() error {
- log.Info("REST module init.")
- rest.router = gin.Default()
- //router.GET("/Gateway4G/UpdateDevcie", hello) // hello函数处理"/hello"请求
- // 指定地址和端口号
- go rest.router.Run(":10001")
- return nil
- }
- func (rest *RestApi) Uninit() {
- }
- func (rest *RestApi) OpenChannel(chnID interface{}, router []chan interface{}) IChannel {
- if reflect.TypeOf(chnID).Kind() != reflect.String {
- log.Error("wrong channel type, REST URL need a string!")
- return nil
- }
- url := chnID.(string)
- log.Info("Rest channel:", url)
- return nil
- }
- func (rest *RestApi) CloseChannel(chn IChannel) error {
- return nil
- }
- func (rest *RestApi) ResetChannel(chn IChannel) {
- }
- func (rest *RestApi) ScanChannel(stream []byte, conn int) IChannel {
- return nil
- }
- func (rest *RestApi) Send(chn IChannel, buff interface{}) (int, error) {
- return 0, nil
- }
- func (rest *RestApi) Recive(chn IChannel, buff interface{}) (int, error) {
- return 0, nil
- }
|