package main import ( "fmt" "log" "net/http" "github.com/dhamidi/ess" ) var SignUp = ess.NewCommandDefinition("sign-up"). Id("username", ess.Id()). Field("name", ess.TrimmedString()). Field("email", ess.EmailAddress()). Field("password", ess.Password()). Target(NewUserFromCommand) func NewUserFromCommand(command *ess.Command) ess.Aggregate { return NewUser(command.Get("username").String()) } type User struct { id string events ess.EventPublisher signedUp bool } func NewUser(username string) *User { return &User{ id: username, }
"encoding/json" "fmt" "log" "net/http" "net/url" "os" "strings" "time" "github.com/dhamidi/ess" ) var ( WritePost = ess.NewCommandDefinition("write-post"). Field("id", ess.Id()). Field("title", ess.TrimmedString()). Field("body", ess.TrimmedString()). Field("username", ess.Id()). Target(PostFromCommand) EditPost = ess.NewCommandDefinition("edit-post"). Field("id", ess.Id()). Field("title", ess.TrimmedString()). Field("body", ess.TrimmedString()). Field("reason", ess.TrimmedString()). Field("username", ess.Id()). Target(PostFromCommand) SignUp = ess.NewCommandDefinition("sign-up"). Id("username", ess.Id()). Field("email", ess.EmailAddress()).