Sha256: 059efc935f85f7d726f6ba1041f6ad29ed34143429b0065e93e7cfb76f747243

Contents?: true

Size: 1020 Bytes

Versions: 14

Compression:

Stored size: 1020 Bytes

Contents

package handlers

import (
	"encoding/json"
	"fmt"
	"net/http"
	"log"

	"github.com/gorilla/context"
	"<%= namespace %>/<%= application_name %>/logging"
)

type EchoDependenciesContainer struct {
	StatsD logging.StatsD `inject:"statsd"`
	Log    *log.Logger    `inject:""`
}

var EchoDependencies *EchoDependenciesContainer = &EchoDependenciesContainer{}
const EHTAGNAME = "EchoHandler: "

// use the validation middleware to automatically validate input
// github.com/asaskevich/govalidator
type Echo struct {
	Echo string `json:"echo" valid:"stringlength(1|255),required"`
}

func EchoHandler(rw http.ResponseWriter, r *http.Request) {
	EchoDependencies.StatsD.Increment(ECHO_HANDLER + POST + CALLED)
	EchoDependencies.Log.Printf("%v Called GET\n", EHTAGNAME)

	// request is set into the context from the middleware
	request := context.Get(r, "request").(*Echo)
	fmt.Println("r: ", request)

	encoder := json.NewEncoder(rw)
	encoder.Encode(request)

	EchoDependencies.StatsD.Increment(ECHO_HANDLER + POST + SUCCESS)
}

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
minke-generator-go-0.8.7 lib/generators/gomicroservice/scaffold/handlers/echo.go.erb
minke-generator-go-0.8.6 lib/generators/gomicroservice/scaffold/handlers/echo.go.erb
minke-generator-go-0.8.5 lib/generators/gomicroservice/scaffold/handlers/echo.go.erb
minke-generator-go-0.8.4 lib/generators/gomicroservice/scaffold/handlers/echo.go.erb
minke-generator-go-0.8.3 lib/generators/gomicroservice/scaffold/handlers/echo.go.erb
minke-generator-go-0.8.2 lib/generators/gomicroservice/scaffold/handlers/echo.go.erb
minke-generator-go-0.8.1 lib/generators/gomicroservice/scaffold/handlers/echo.go.erb
minke-generator-go-0.8.0 lib/generators/gomicroservice/scaffold/handlers/echo.go.erb
minke-generator-go-0.7.2 lib/generators/gomicroservice/scaffold/handlers/echo.go.erb
minke-generator-go-0.7.1 lib/generators/gomicroservice/scaffold/handlers/echo.go.erb
minke-generator-go-0.7.0 lib/generators/gomicroservice/scaffold/handlers/echo.go.erb
minke-generator-go-0.6.0 lib/generators/gomicroservice/scaffold/handlers/echo.go.erb
minke-generator-go-0.5.0 lib/generators/gomicroservice/scaffold/handlers/echo.go.erb
minke-generator-go-0.4.0 lib/generators/gomicroservice/scaffold/handlers/echo.go.erb