Skip to content

Add New /dog Route with Random Response

Add Dog Handler Endpoint

Summary

This PR adds a new /api/dog endpoint to the animals API service that randomly returns either "woof" or "bark" when called.

Changes

  • Added new DogHandler with randomization logic
  • Implemented handler tests for the dog endpoint
  • Updated README with new endpoint documentation
  • Extended routing configuration to include dog endpoint

Technical Details

  • Uses math/rand for sound randomization
  • Follows existing handler pattern with BaseHandler embedding
  • Includes comprehensive test coverage for the new endpoint
  • Unique response format that returns only the sound (differs from other handlers)

Testing

  • Added unit tests for all DogHandler functionality
  • Verified random sound generation
  • Tested HTTP method restrictions
  • Endpoint can be tested locally using: curl http://localhost:8080/api/dog

Merge request reports

Loading