Skip to content

Simple go-application that interacts with different open api's to create text that you can receive on GET endpoints.

Notifications You must be signed in to change notification settings

dllg/go-funny-endpoints

Repository files navigation

test results

Funny endpoints

Simple go-application that interacts with different open api's to create text that you can receive on GET endpoints. See swagger.yml.

It uses gin web framework to handle http requests. For logging it uses logrus.

Testing

Testing of funny.go is done using dependency injection. Mocking of httpclient is done using mockgen.

Testing of router.go is done using package httptest.

Building

For local computer

Use make to build the application:

make build

For docker

Use make to build the application in docker:

make docker-build

Running

Locally

The application will be put in the build folder. To run it invoke:

export PORT="18080"
./build/go-funny-endpoints

In docker

Use docker-compose to start the application:

docker-compose up -d

Examples of using it

Get an advice

$ curl http://localhost:18080/v1/advice
{"message":"If you don't want something to be public, don't post it on the Internet."}

Get a Chuck Norris Joke

$ curl http://localhost:18080/v1/chucknorris
{"message":"there is no use crying over spilled milk, unless its Chuck Norris' milk because then your gonna die"}

Get a dad joke

$ curl http://localhost:18080/v1/dadjoke
{"message":"What do you call an eagle who can play the piano? Talonted!"}

Get a random message

$ curl http://localhost:18080/v1/random
{"message":"Advice: When painting a room, preparation is key. The actual painting should account for about 40% of the work."}

About

Simple go-application that interacts with different open api's to create text that you can receive on GET endpoints.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published