Documentation ¶
Overview ¶
Package handlers provides the endpoints for the web service.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SendJSON ¶
func SendJSON(rw http.ResponseWriter, r *http.Request)
SendJSON returns a simple JSON document.
Example ¶
ExampleSendJSON provides a basic example example.
package main import ( "encoding/json" "fmt" "log" "net/http" "net/http/httptest" ) func main() { r := httptest.NewRequest("GET", "/sendjson", nil) w := httptest.NewRecorder() http.DefaultServeMux.ServeHTTP(w, r) var u struct { Name string Email string } if err := json.NewDecoder(w.Body).Decode(&u); err != nil { log.Println("ERROR:", err) } fmt.Println(u) }
Output: {Bill bill@ardanlabs.com}
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.