handlers

package
v0.0.0-...-8d8d9e6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2016 License: Apache-2.0 Imports: 2 Imported by: 0

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 Routes

func Routes()

Routes sets the routes for the web service.

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, _ := http.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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL