package de.fete.config;

import java.time.Clock;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/** Configures API path prefix. Static resources served by default Spring Boot handler. */
@Configuration
public class WebConfig implements WebMvcConfigurer {

  /** Provides a system clock bean for time-dependent services. */
  @Bean
  Clock clock() {
    return Clock.systemDefaultZone();
  }

  @Override
  public void configurePathMatch(PathMatchConfigurer configurer) {
    configurer.addPathPrefix("/api", c -> c.isAnnotationPresent(RestController.class));
  }
}
