A random collection of go utilities/servers etc

go get



A random collection of go utilities/servers etc


go install nagiworld/proxy

Proxy Server Usage

import  "nagiworld/proxy"

func main() {
     // starts proxy server on localhost:<port>
curl -x localhost:8090

JsonServer Usage:

The json server abstracts out all the http handler interface to present a simple func that can look at the request and return any json object. The server handles the http headers/marshalling for you.

All thats needed is to provide a func(r *http.Request)_ and returns the data as a json struct

import "nagiworld/jsonserver"

fooHandler := func(r *http.Request) (interface{}, error) {
      //  Look into the request and return a struct 
      return &Employee{ID: 2, Name:"foo", Age:20, Salary:500}

func main() {
     // Once created we then register it with the handler 
     jsonserver.RegisterHandler("/foo", fooHandler)
     jsonserver.StartServer("localhost", 8080)


To run the json server you can issue go run jServer.go. By default the server runs on port 8080. To see the json output, run the following curl cmd.

curl -v http://localhost:8080/baz/123


curl -v http://localhost:8080/foo