Open ashtonian opened 4 years ago
example body:
[
{
"op":"test",
"path":"/a/b/c",
"value":"foo"
},
{
"op":"remove",
"path":"/a/b/c"
},
{
"op":"add",
"path":"/a/b/c",
"value":[
"foo",
"bar"
]
},
{
"op":"replace",
"path":"/a/b/c",
"value":42
},
{
"op":"move",
"from":"/a/b/c",
"path":"/a/b/d"
},
{
"op":"copy",
"from":"/a/b/d",
"path":"/a/b/e"
}
]
limit to replace (+ maybe remove) implementation initially.
Ideal: ParseFields, verify name, verify type, verify op is allowed.
Patchy:
type Op struct {
Operation string
From string
Path String
Value interface{}
}
// created using reflection once, then used every query to generate sql.
type PatchSpec struct {
TargetResource string
Fields []PatchField
}
type PatchField struct {
AllowedOps string
TargetType string
Validator func // only need two funcs
Converter func
Filter func
}
func (op *Op) GetValue() interface{} {
}
type Error struct {
Attempted Op
Reason string
Code int // custom
}
allow 201 status code with soft rejections. SQL util to generate sql statement from []OP.
Proper patch, multi resource, support multiple resources same query. diff between null, undefined, and "" or 0.