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