2024-10-04 03:58:44 +00:00
|
|
|
package apiconfig
|
|
|
|
|
|
|
|
import "encoding/json"
|
|
|
|
|
|
|
|
type RequestType string
|
|
|
|
|
|
|
|
const (
|
|
|
|
JSON RequestType = "json"
|
|
|
|
FormData RequestType = "form-data"
|
|
|
|
)
|
|
|
|
|
|
|
|
type APIConfig struct {
|
|
|
|
ID string `json:"id"`
|
|
|
|
ListenPath string `json:"listenPath"`
|
|
|
|
Method string `json:"method"`
|
|
|
|
Request RequestConfig `json:"request"`
|
|
|
|
Actions map[string]Action `json:"actions"`
|
|
|
|
Conditionals map[string]Conditional `json:"conditionals"`
|
|
|
|
Responses map[string]ResponseConfig `json:"responses"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type RequestConfig struct {
|
|
|
|
Type RequestType `json:"type"`
|
|
|
|
Schema string `json:"schema"`
|
|
|
|
FormValues []string `json:"formValues"`
|
|
|
|
Next string `json:"next"`
|
|
|
|
CORSAllowedOrigins []string `json:"corsAllowedOrigins"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Action struct {
|
|
|
|
Type string `json:"type"`
|
|
|
|
Config json.RawMessage `json:"config"`
|
|
|
|
Next string `json:"next"`
|
2024-10-13 03:27:46 +00:00
|
|
|
Fail string `json:"fail"`
|
2024-10-04 03:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type ConditionalExpressions struct {
|
|
|
|
Value string `json:"value"`
|
|
|
|
Type string `json:"type"`
|
|
|
|
Compare string `json:"compare,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Conditional struct {
|
|
|
|
ValidPath string `json:"validPath"`
|
|
|
|
InvalidPath string `json:"invalidPath"`
|
|
|
|
Expression string `json:"expression"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ActionConfig struct {
|
|
|
|
ID string
|
|
|
|
Type string
|
|
|
|
Configuration string
|
|
|
|
}
|
|
|
|
|
|
|
|
type ResponseConfig struct {
|
|
|
|
Code int `json:"code"`
|
|
|
|
Template string `json:"template"`
|
|
|
|
Type string `json:"type"`
|
|
|
|
}
|
2024-10-05 03:58:51 +00:00
|
|
|
|
|
|
|
type DatasourceConfig struct {
|
|
|
|
ID string `json:"id"`
|
|
|
|
Config json.RawMessage `json:"config"`
|
|
|
|
Type string `json:"type"`
|
|
|
|
}
|