handlers

package
v0.0.0-...-b3f521c Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2017 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 := 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.

Jump to

Keyboard shortcuts

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