Instruction file imported from aaronhunter1088/PokedexWithSpringBoot (
.github/instructions/controller.instructions.md). Copyright stays with the author.
Apply these instructions when adding or editing controller classes in the project.
- Keep controllers annotated with
@Controllerand use constructor injection with@Autowiredon the constructor, matching the existing inheritance fromBaseController. - Prefer extending
BaseControllerfor shared behavior such as Pokemon enrichment, dark mode, GIF toggles, pagination state, and fallback API access. - Use a private static logger via
LogManager.getLogger(...)in each controller. - Keep controller methods small and endpoint-focused; delegate enrichment and mapping work to
BaseControllerhelpers likecreatePokemon(...),retrievePokemon(...), andsetupPokedex(...). - Preserve the existing endpoint layout and response style:
IndexController:/,/page,/pkmnPerPage,/getPokemonByType,/toggleGifs,/toggleDarkmodePokedexController:/pokedex/{nameOrId}EvolutionsController:/evolutions/{pokemonId}EvolvesHowController:pokemonIdrequest parameter andevolves-howfragment renderingSearchController:/search
- Use
ModelAndViewfor server-rendered views andResponseEntity/@ResponseBodyonly for simple JSON or text responses. - Preserve the two-step species lookup pattern when needed: call
pokemonService.getPokemonSpeciesData(...)first, then fall back topokemonService.callUrl(...)plusObjectMappermapping. - Keep session and UI state changes consistent with the existing services (
DarkmodeService,GifService) and avoid duplicating state logic outside the shared base controller unless necessary. - Maintain server-rendered AJAX fragment behavior for
pokedex.jspand related views; do not switch these flows to client-side rendering unless the whole flow is being redesigned. - Keep request parameter and path variable names aligned with existing controller and JSP usage (
darkmode,pageNumber,pkmnPerPage,chosenType,pokemonId,nameOrId).