stringsvc

command
v0.0.0-...-62c0869 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2019 License: MIT Imports: 7 Imported by: 0

README

stringservice example

This example is based on go-kit's example String Service. In order to utilize this example, the command has been written for you, however the generated layers have no been committed, and no binary exists. To this effect a couple of steps should be taken to get this working.

Generate the Layers

First, the layers for the example service need to be generated. This can be done by following these steps:

  • Open a Shell/Terminal
  • Navigate to The String Service Path: cd $GOPATH/src/github.com/fish2016/go-kit-middlewarer/examples/stringsvc
  • Run go's generate command: go generate
Build the Binary

Next the binary itself will need to be built. This binary is already written to import the layers that were generated by assuming that it is still in your GOPATH. So building or installing the binary should be easy.

  • Open a Shell/Terminal
  • Navigate to the StringService command's main.go folder: cd $GOPATH/src/github.com/fish2016/go-kit-middlewarer/examples/stringsvc/cmd/stringsvc
  • Build or install the command: go build . or go install
Testing the Service

Testing the result should be fairly simple, provided you have the curl command. At this point, all you should have to do is launch the service. ./stringsvc if it is in the current working directory, and not in your PATH environment variable, or just stringsvc if it is.

Once that is running, in another Terminal/Shell instance, you can use curl to make a request against the service:

curl localhost:9000/stringservice/uppercase -H 'Content-Type: application/json' -d '{"str": "this is a test"}'
Some minor notes

If the default port, 9000 doesn't work for you, you can change it in the source.

The Content-Type should be supplied for the request in order for it to be decoded effectively. However, if it is not supplied, the encoding package will attempt to determine the encoding by sniffing it, and then by brute-force if need be.

TODOs
  • allow the bind address to be overwritten via a commandline argument
  • default to localhost:9000, for the bind address.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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