February 2019
Intermediate to advanced
450 pages
11h 59m
English
Posting data to a web service should be just as easy as changing a Get() function call to a Post() but there are often complications. Consider our email example and the task of connecting to Gmail. The API is straightforward and we can easily make the request, but the data must be appropriately formatted. Emails have complex encodings when sent to mail servers and we need to implement that to work with the API. The Gmail service requires an RFC 2822 encoded email (which the Go standard library doesn't provide), which is then base64url encoded (the standard library can handle this). Before we can post any email messages, we need to add an encoder to our EmailMessage type, as follows:
func (e *EmailMessage) ToGMailEncoding() string ...Read now
Unlock full access