2018-09-27 11:43:36 +00:00
|
|
|
package driver
|
|
|
|
|
|
|
|
import (
|
2018-10-07 09:23:00 +00:00
|
|
|
"git.xdrm.io/go/aicra/api"
|
2018-09-28 08:54:13 +00:00
|
|
|
"net/http"
|
2018-09-27 11:43:36 +00:00
|
|
|
)
|
|
|
|
|
2018-09-28 06:10:41 +00:00
|
|
|
// Driver defines the driver interface to load controller/middleware implementation or executables
|
2018-09-27 11:43:36 +00:00
|
|
|
type Driver interface {
|
2018-09-28 13:58:30 +00:00
|
|
|
Name() string
|
2018-10-01 10:29:05 +00:00
|
|
|
Path(string, string, string) string
|
|
|
|
Source(string, string, string) string
|
|
|
|
Build(string, string, string) string
|
|
|
|
Compiled() bool
|
|
|
|
|
2018-10-01 17:27:38 +00:00
|
|
|
LoadController(_path string) (Controller, error)
|
|
|
|
LoadMiddleware(_path string) (Middleware, error)
|
|
|
|
LoadChecker(_path string) (Checker, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Checker is the interface that type checkers implementation must follow
|
|
|
|
type Checker interface {
|
|
|
|
Match(string) bool
|
|
|
|
Check(interface{}) bool
|
2018-09-27 11:43:36 +00:00
|
|
|
}
|
|
|
|
|
2018-09-29 15:01:58 +00:00
|
|
|
// Controller is the interface that controller implementation must follow
|
|
|
|
// it is used by the 'Import' driver
|
|
|
|
type Controller interface {
|
2018-10-07 09:23:00 +00:00
|
|
|
Get(d api.Arguments) api.Response
|
|
|
|
Post(d api.Arguments) api.Response
|
|
|
|
Put(d api.Arguments) api.Response
|
|
|
|
Delete(d api.Arguments) api.Response
|
2018-09-29 15:01:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Middleware is the interface that middleware implementation must follow
|
|
|
|
// it is used by the 'Import' driver
|
|
|
|
type Middleware interface {
|
|
|
|
Inspect(http.Request, *[]string)
|
|
|
|
}
|