This starting API service is quite straight forward. To build the binary,
- pull the code
git clone git@github.com:goyeh/gowebserve.git or git pull git@github.com:goyeh/gowebserve.git
- inside the home fold run the make program.
you should get something the looks like the following. the http frame work and the env file reader
make
make go clean rm -f go get github.com/valyala/fasthttp go get github.com/joho/godotenv go build -o connect-api -v
- simple run the binary file.
connect-api
- test the program
you should see something like:
curl localhost:8000/login
Request method is "GET" RequestURI is "/test" Requested path is "/test" Host is "localhost:8000" Query string is "" User-Agent is "curl/7.54.0" Connection has been established at 2019-10-23 12:16:23.595999 +0800 HKT m=+75.066635474 Request has been started at 2019-10-23 12:16:23.596017 +0800 HKT m=+75.066653094 Serial request number for the current connection is 1 Your ip is "127.0.0.1"
- another test with paramaters
the result should present the method you can use to pass paramters to the web site.
curl localhost:8000/test?fred=bob
Request method is "GET" RequestURI is "/test?fred=bob" Requested path is "/test" Host is "localhost:8010" Query string is "fred=bob" User-Agent is "curl/7.54.0" Connection has been established at 2019-10-23 12:17:59.502669 +0800 HKT m=+170.970428060 Request has been started at 2019-10-23 12:17:59.502684 +0800 HKT m=+170.970443046 Serial request number for the current connection is 1 Your ip is "127.0.0.1"
Feel free to message me, or send email to tipton[at]mysecretroom.com I am stationed in Hong Kong, and enjoy programming challenges.