Project

General

Profile

Golang API server » History » Version 3

Peter Amstutz, 08/09/2018 06:12 PM

1 1 Peter Amstutz
h1. Golang API server
2
3 2 Peter Amstutz
Currently thinking about how to structure the callbacks that happen when updating and saving a record.
4
5
Types of callbacks:
6
7
* Fix-ups: modifying a column value, for example, stripping signatures from manifest_text
8
* Fill-ins: setting certain columns implies filling in another value (for example, setting portable_data_hash from manifest_text)
9
* Transitions: check that it semantically valid to go to record state Y from record state X (eg X and Y may both be valid, but going (X → Y) may not be valid)
10
* Permissions: check that the user making the request is allowed to make that modification
11
* Validations: check that a given record value is valid
12
13
Callbacks are very sensitive to ordering.  For example, a record may not pass Validation until a Fix-up has been applied.  Transition checks may occur before or after Fill-ins or Fix-ups.
14
15
Callback types have different contracts:
16 1 Peter Amstutz
17
Fix-up and Fill-in operations potentially modify the update operation.  Transition and Permission validations rely on both the before and after state.  Plain Validation checks only look at the current state, but may apply to both create and update requests.
18 3 Peter Amstutz
19
h2. Existing code
20
21
Struct validation https://github.com/go-ozzo/ozzo-validation
22
23
Generate Golang structs from Rails ActiveRecord
24
25
https://github.com/t-k/ar2gostruct