Module 11 Β· Bookings β Lesson 2 of 3 Β· ~11 min
Creating a booking
From request to record
A POST /bookings arrives carrying a walker id, a user id, a duration, and a time. Your handler's job is to turn that raw request into a real Booking: decode the body, figure out the price, stamp it pending, and answer 201 Created with the finished record.
You already know the front half β decode with json.NewDecoder(r.Body).Decode(&req) and reject bad JSON with a 400. This lesson is about the middle: computing the fields the server owns, not the ones the client sent.