Skip to content

Add New /dog Route with Random Response

Description

Add a new endpoint /dog to the microservice that randomly returns either "woof" or "bark" when called with a GET request.

Technical Requirements

  • Add new route /dog that accepts GET requests
  • Implement random selection between two possible responses: "woof" or "bark"
  • Follow existing project structure and coding standards
  • Add appropriate unit tests
  • Update readme

Implementation Details

Create new handler

  • Add DogHandler struct in handlers package
  • Implement handler method with random response logic
  • Use Go's math/rand package for randomization

Update routing

  • Add new route to router setup
  • Group with existing endpoints under /api prefix

Testing

  • Add unit tests for the new handler
  • Test both possible responses
  • Test invalid HTTP methods

Documentation

  • Add example usage in README