Skip to content

A simple wrapper around a go-kit endpoint that provides context for each endpoint request/response

License

Notifications You must be signed in to change notification settings

jwenz723/gokit-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Goal

Demonstrate how to use the kit-mw middlewares.

Running the code

This service is almost a direct copy of addsvc.

Start up the service

go run cmd/main.go 

Send in a concat and sum request

$ curl -d '{"a":"2","b":"3"}' localhost:8081/concat
  {"v":"23"}
$ curl -d '{"a":2,"b":3}' localhost:8081/sum       
  {"v":5}

See the keyvals printed for each request/response (the keys start with ConcatRequest, ConcatResponse, SumRequest., and SumResponse.):

level=info ts=2019-07-26T08:00:38.638877Z caller=eplogger.go:56 method=Concat transport_error=null took=7.985µs ConcatRequest.A=2 ConcatRequest.B=3 ConcatResponse.V=23 ConcatResponse.Err=null
level=info ts=2019-07-26T08:00:44.300104Z caller=eplogger.go:56 method=Sum transport_error=null took=4.071µs SumRequest.A=2 SumRequest.B=3 SumResponse.R=5 SumResponse.Err=null

About

A simple wrapper around a go-kit endpoint that provides context for each endpoint request/response

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages