Home > OS >  Kong - installing/Setting up a Golang microservice - why does it not work?
Kong - installing/Setting up a Golang microservice - why does it not work?

Time:11-21

Absolute Kong noob here; I have a small Golang docker container running a simple Api which just returns the datetime (port 3000). Checked by running http://localhost:3000/timecheck - works.

Installed Kong DB version Postgress conform the Kong instructions.

Created a service:

curl -i -s -X POST http://localhost:8001/services \
  --data 'name=ts' \
  --data 'url=http://0.0.0.0:3000'

201 Created

Setup the route:


curl -i -X POST http://localhost:8001/services/ts/routes \
  --data 'paths[]=/ts' \
  --data 'name=ts'

201 created


checked with: curl -X GET http://localhost:8001/services/ts/routes/ts

If I go to http://localhost:8000/ts name resolution failed..

or 

http://localhost:8000/timecheck (timecheck being the handler in Golang)

I am doing something VERY wrong? ANY help would be apperciated!!

CodePudding user response:

request to localhost:8000/timecheck does NOT work

Kong is installed on Docker

CodePudding user response:

Since both your Go application and Kong are deployed on Docker, If both of your apps are in the same network they should be able to refer to each other based on docker service name.

When you're creating a service, the URL should be <service-name>

curl -i -s -X POST http://localhost:8001/services \
--data 'name=ts' \
--data 'url=http://<service-name>'

Afterward, a request to http://localhost:8000/ts should work.

  • Related