Skip to content

Commit

Permalink
List endpoints on application startup
Browse files Browse the repository at this point in the history
  • Loading branch information
Matias Schilling committed Jun 30, 2024
1 parent 6c17932 commit 30ffd70
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
package io.chucknorris.api;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

@ComponentScan(basePackages = { "io.chucknorris" })
@EnableJpaAuditing
@Slf4j
@SpringBootApplication
public class Application {
public class Application implements ApplicationListener<ContextRefreshedEvent> {

@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
event
.getApplicationContext()
.getBean(RequestMappingHandlerMapping.class)
.getHandlerMethods()
.keySet()
.forEach(it -> log.info("Mapped endpoint: {}", it));
}

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
Expand Down

0 comments on commit 30ffd70

Please sign in to comment.