DEV Community

Discussion on: Build Your First Rest API with GO

Collapse
 
ryanmccormick profile image
Ryan McCormick

Great primer for writing REST APIs in golang. I am a go newbie and stumbled on to this article. Quick note about some of the example code for typo fix or for anyone else working through the example:

The beginning of the exercise has the w.WriteHeader and w.Header().Set lines flip-flopped.
while running the example at the beginning I kept getting "text/plain" for my response content type instead of "application/json". It looks to be correct elsewhere but w.Header().Set should be called before w.WriteHeader. According to docs: "Changing the header map after a call to WriteHeader (or Write) has no effect unless the modified headers are trailers".

Collapse
 
moficodes profile image
Mofi Rahman

Thanks for catching that.

Fixed it.