Skip to content

Commit

Permalink
Merge pull request #478 from VerisimilitudeX/deepsource-transform-1e2…
Browse files Browse the repository at this point in the history
…6cb01

style: format code with Autopep8 and Google Java Format
  • Loading branch information
VerisimilitudeX authored Feb 24, 2025
2 parents 94bb1ca + a619107 commit c63c829
Show file tree
Hide file tree
Showing 2 changed files with 263 additions and 260 deletions.
74 changes: 38 additions & 36 deletions src/main/java/DNAnalyzer/DNAnalyzerApplication.java
Original file line number Diff line number Diff line change
@@ -1,50 +1,52 @@
package DNAnalyzer;

import java.util.Map;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.boot.web.servlet.error.DefaultErrorAttributes;
import org.springframework.boot.web.servlet.error.ErrorAttributes;
import org.springframework.context.annotation.Bean;
import org.springframework.web.context.request.WebRequest;
import java.util.Map;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
* Spring Boot Application configuration for DNAnalyzer web server.
* Handles web-specific configuration like CORS settings.
* Spring Boot Application configuration for DNAnalyzer web server. Handles web-specific
* configuration like CORS settings.
*/
@SpringBootApplication
public class DNAnalyzerApplication {

/**
* Configure CORS for the web server.
* Allows web interface to communicate with the local analyzer.
*/
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/api/**")
.allowedOrigins("*")
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
.allowedHeaders("*")
.maxAge(3600);
}
};
}
/**
* Configure CORS for the web server. Allows web interface to communicate with the local analyzer.
*/
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry
.addMapping("/api/**")
.allowedOrigins("*")
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
.allowedHeaders("*")
.maxAge(3600);
}
};
}

@Bean
public ErrorAttributes errorAttributes() {
return new DefaultErrorAttributes() {
@Override
public Map<String, Object> getErrorAttributes(WebRequest webRequest, boolean includeStackTrace) {
Map<String, Object> errorAttributes = super.getErrorAttributes(webRequest, includeStackTrace);
errorAttributes.put("status", errorAttributes.get("status"));
errorAttributes.put("error", errorAttributes.get("error"));
errorAttributes.put("message", errorAttributes.get("message"));
return errorAttributes;
}
};
}
@Bean
public ErrorAttributes errorAttributes() {
return new DefaultErrorAttributes() {
@Override
public Map<String, Object> getErrorAttributes(
WebRequest webRequest, boolean includeStackTrace) {
Map<String, Object> errorAttributes =
super.getErrorAttributes(webRequest, includeStackTrace);
errorAttributes.put("status", errorAttributes.get("status"));
errorAttributes.put("error", errorAttributes.get("error"));
errorAttributes.put("message", errorAttributes.get("message"));
return errorAttributes;
}
};
}
}
Loading

0 comments on commit c63c829

Please sign in to comment.