refactor: executors and routers
* refactor: executors and routers
This commit is contained in:
@@ -1,26 +1,30 @@
|
||||
package rest
|
||||
|
||||
/*
|
||||
Full list of requirements must be updated when adding new command:
|
||||
import "encoding/json"
|
||||
|
||||
required_without_all=Vote DeclarePeace DeclareWar
|
||||
| excluded_with=Vote DeclarePeace DeclareWar
|
||||
*/
|
||||
type Command struct {
|
||||
Race string `json:"race" binding:"required,notblank"`
|
||||
Vote *CommandVote `json:"vote" binding:"required_without_all=DeclarePeace DeclareWar,excluded_with=DeclarePeace DeclareWar"`
|
||||
DeclarePeace *CommandDeclarePeace `json:"declarePeace" binding:"required_without_all=Vote DeclareWar,excluded_with=Vote DeclareWar"`
|
||||
DeclareWar *CommandDeclareWar `json:"declareWar" binding:"required_without_all=Vote DeclarePeace,excluded_with=Vote DeclarePeace"`
|
||||
Actor string `json:"actor" binding:"required,notblank"`
|
||||
Commands []json.RawMessage `json:"cmd" binding:"min=1"`
|
||||
}
|
||||
|
||||
type CommandType string
|
||||
|
||||
const (
|
||||
CommandTypeVote CommandType = "vote"
|
||||
CommandTypeRelation CommandType = "declarePeace"
|
||||
)
|
||||
|
||||
type CommandMeta struct {
|
||||
Type CommandType `json:"@type"`
|
||||
}
|
||||
|
||||
type CommandVote struct {
|
||||
CommandMeta
|
||||
Recipient string `json:"recipient" binding:"required,notblank"`
|
||||
}
|
||||
|
||||
type CommandDeclarePeace struct {
|
||||
Opponent string `json:"recipient" binding:"required,notblank"`
|
||||
}
|
||||
|
||||
type CommandDeclareWar struct {
|
||||
type CommandUpdateRelation struct {
|
||||
CommandMeta
|
||||
Opponent string `json:"recipient" binding:"required,notblank"`
|
||||
Relation string `json:"relation" binding:"required,notblank"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user