router.go 658 字节
Newer Older
Y
Your Name 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
package router

import (
	"net/http"

	"github.com/eolinker/goku-api-gateway/goku-node/common"
)

//IRouter iRouter
type IRouter interface {
	Router(ctx *common.Context)
}

//HandleFunc handlefunc
type HandleFunc func(ctx *common.Context)

//Router router
func (handlerFunc HandleFunc) Router(ctx *common.Context) {
	handlerFunc(ctx)
}

//APIRouter apiRouter
type APIRouter interface {
	AddRouter(method, path string, router IRouter)
	HandleFunc(method, path string, handler HandleFunc)
	AddNotFound(handle HandleFunc)
	ServeHTTP(w http.ResponseWriter, req *http.Request, ctx *common.Context)
}

//Factory factory
type Factory interface {
	New() APIRouter
}