regular routes journeys, persistent KV to store return states, ...

This commit is contained in:
2023-04-03 20:35:12 +02:00
parent 0ae5730e7f
commit 2f536dfb19
21 changed files with 1722 additions and 1070 deletions

View File

@@ -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"`