regular routes journeys, persistent KV to store return states, ...
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
package ocss
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type Gender int64
|
||||
|
||||
const (
|
||||
@@ -8,6 +13,36 @@ const (
|
||||
Other
|
||||
)
|
||||
|
||||
var gendertoID = map[string]Gender{
|
||||
"F": Female,
|
||||
"M": Male,
|
||||
"O": Other,
|
||||
}
|
||||
|
||||
var gendertoString = map[Gender]string{
|
||||
Female: "F",
|
||||
Male: "M",
|
||||
Other: "O",
|
||||
}
|
||||
|
||||
func (s Gender) MarshalJSON() ([]byte, error) {
|
||||
buffer := bytes.NewBufferString(`"`)
|
||||
buffer.WriteString(gendertoString[s])
|
||||
buffer.WriteString(`"`)
|
||||
return buffer.Bytes(), nil
|
||||
}
|
||||
|
||||
func (bs *Gender) UnmarshalJSON(b []byte) error {
|
||||
var j string
|
||||
err := json.Unmarshal(b, &j)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Note that if the string cannot be found then it will be set to the zero value, 'Created' in this case.
|
||||
*bs = gendertoID[j]
|
||||
return nil
|
||||
}
|
||||
|
||||
type User struct {
|
||||
ID string `json:"id"`
|
||||
Operator string `json:"operator"`
|
||||
|
||||
Reference in New Issue
Block a user