net/http: This is available out of the box in Go language. Package "net/http" provides HTTP client and server implementations which can be used to make common HTTP requests like GET, POST, PUT, DELETE e.t.c.. While building REST Api's with Go using net/http , here are few methods and interfaces we should understand: type Handler type Handler interface { ServeHTTP(ResponseWriter, * Request) } - A Handler is responsible for responding to HTTP requests. This interface has only one method ServeHTTP(ResponserWriter, *Request) - You can define your own struct as a Handler which implements ServeHTTP method with ResponseWriter and pointer to Request as arguments package main import ( "net/http" ) type server struct {} func (s * server) ServeHTTP(writer http.ResponseWriter, req * http.Request) { writer.Header().Set( "Content-Type" , "application/json" ) writer.WriteHeader(http.StatusOK) writer...
Scribble-pad of a humble, hungry and foolish engineer. "Stay Hungry, Stay Foolish" -Steve Jobs