2018-09-27 12:11:48 +00:00
|
|
|
package driver
|
|
|
|
|
|
|
|
import (
|
2018-10-01 10:29:05 +00:00
|
|
|
"path/filepath"
|
2018-09-27 12:11:48 +00:00
|
|
|
)
|
|
|
|
|
2018-10-01 15:43:18 +00:00
|
|
|
// Generic tells the aicra instance to use the generic driver to load controller/middleware executables
|
|
|
|
//
|
|
|
|
// It will call an executable with the json input into the standard input (argument 1)
|
|
|
|
// the HTTP method is send as the key _HTTP_METHOD_ (in upper case)
|
|
|
|
// The standard output must be a json corresponding to the data
|
|
|
|
type Generic struct{}
|
|
|
|
|
2018-09-28 16:30:49 +00:00
|
|
|
// Name returns the driver name
|
2018-09-28 13:58:30 +00:00
|
|
|
func (d *Generic) Name() string { return "generic" }
|
|
|
|
|
2018-10-01 10:29:05 +00:00
|
|
|
// Path returns the universal path from the source path
|
|
|
|
func (d Generic) Path(_root, _folder, _src string) string {
|
|
|
|
return _src
|
|
|
|
}
|
|
|
|
|
|
|
|
// Source returns the source path from the universal path
|
|
|
|
func (d Generic) Source(_root, _folder, _path string) string {
|
|
|
|
return filepath.Join(_root, _folder, _path)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Build returns the build path from the universal path
|
|
|
|
func (d Generic) Build(_root, _folder, _path string) string {
|
|
|
|
return filepath.Join(_root, _folder, _path)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Compiled returns whether the driver has to be build
|
|
|
|
func (d Generic) Compiled() bool { return false }
|
|
|
|
|
2018-10-01 17:27:38 +00:00
|
|
|
// LoadController implements the Driver interface
|
|
|
|
func (d *Generic) LoadController(_path string) (Controller, error) {
|
|
|
|
return GenericController(_path), nil
|
2018-09-27 12:11:48 +00:00
|
|
|
}
|
2018-09-28 09:08:44 +00:00
|
|
|
|
2018-10-01 17:27:38 +00:00
|
|
|
// LoadMiddleware returns a new middleware; it must be a
|
2018-09-28 09:08:44 +00:00
|
|
|
// valid and existing folder/filename file
|
2018-10-01 17:27:38 +00:00
|
|
|
func (d *Generic) LoadMiddleware(_path string) (Middleware, error) {
|
|
|
|
return GenericMiddleware(_path), nil
|
|
|
|
}
|
2018-09-28 09:08:44 +00:00
|
|
|
|
2018-10-01 17:27:38 +00:00
|
|
|
// LoadChecker returns a new middleware; it must be a
|
|
|
|
// valid and existing folder/filename file
|
|
|
|
func (d *Generic) LoadChecker(_path string) (Checker, error) {
|
|
|
|
return GenericChecker(_path), nil
|
2018-09-28 09:08:44 +00:00
|
|
|
}
|