Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion src/main/java/com/example/newsper/config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,46 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.IOException;
import java.util.List;

@Configuration
public class WebConfig {
public class WebConfig implements WebMvcConfigurer {

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
String homePath = "/home/casper/";
registry.addResourceHandler("/profile/**")
.addResourceLocations("file://" + homePath + "profile/");
registry.addResourceHandler("/article/**")
.addResourceLocations("file://" + homePath + "article/");
registry.addResourceHandler("/assignment/**")
.addResourceLocations("file://" + homePath + "assignment/");
registry.addResourceHandler("/submit/**")
.addResourceLocations("file://" + homePath + "submit/");
}

@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("*")
.allowedHeaders("*")
.allowCredentials(false);
}

@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
PageableHandlerMethodArgumentResolver resolver = new PageableHandlerMethodArgumentResolver();
resolver.setOneIndexedParameters(true);
argumentResolvers.add(resolver);
}

@Bean
public FilterRegistrationBean<FileDownloadFilter> fileDownloadFilter() {
Expand Down
31 changes: 0 additions & 31 deletions src/main/java/com/example/newsper/config/WebMvcConfig.java

This file was deleted.