mirror of
https://github.com/safing/portbase
synced 2025-09-01 18:19:57 +00:00
Switch to dsd format for incoming requests
This commit is contained in:
parent
1133c78f85
commit
a8e7d0ecc7
1 changed files with 13 additions and 4 deletions
|
@ -420,11 +420,20 @@ func (api *DatabaseAPI) handlePut(opID []byte, key string, data []byte, create b
|
|||
// 129|success
|
||||
// 129|error|<message>
|
||||
|
||||
raw := make([]byte, len(data)+1)
|
||||
raw[0] = record.JSON
|
||||
copy(raw[1:], data)
|
||||
if len(data) < 2 {
|
||||
api.send(opID, dbMsgTypeError, "bad request: malformed message", nil)
|
||||
return
|
||||
}
|
||||
|
||||
r, err := record.NewWrapper(key, nil, record.JSON, data)
|
||||
// FIXME: remove transition code
|
||||
if data[0] != record.JSON {
|
||||
typedData := make([]byte, len(data)+1)
|
||||
typedData[0] = record.JSON
|
||||
copy(typedData[1:], data)
|
||||
data = typedData
|
||||
}
|
||||
|
||||
r, err := record.NewWrapper(key, nil, data[0], data[1:])
|
||||
if err != nil {
|
||||
api.send(opID, dbMsgTypeError, err.Error(), nil)
|
||||
return
|
||||
|
|
Loading…
Add table
Reference in a new issue