package org.holer.server.config;

import org.holer.server.interceptor.ApiInterceptor;
import org.holer.server.interceptor.ViewInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class HolerWebConfig implements WebMvcConfigurer {
  @Autowired
  private ApiInterceptor apiInterceptor;
  @Autowired
  private ViewInterceptor viewInterceptor;
  
  public void addInterceptors(InterceptorRegistry registry) {
    InterceptorRegistration apiRegistration = registry.addInterceptor(this.apiInterceptor);
    InterceptorRegistration viewRegistration = registry.addInterceptor(this.viewInterceptor);
    apiRegistration.addPathPatterns("/api/**");
    viewRegistration.addPathPatterns("/view/**");
  }
}
