Grokking Advanced Go
0% completed
Request Validation and Error Responses
The handler below decodes a new order and answers 201. The client has misspelled one field name, and the handler reports success anyway.
Output:
201 order for Ana, total 0 cents
The decoder ignored quantiti, the quantity stayed at zero, and an order worth 2,500 cents was recorded as worth nothing. This handler has two further problems. It will read a body of any size, and it sends the raw error text of the decoder to the client.
Each problem has a small repair
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%