Skip to content

Commit

Permalink
style: format code with Autopep8 and Google Java Format
Browse files Browse the repository at this point in the history
This commit fixes the style issues introduced in 0b5366c according to the output
from Autopep8 and Google Java Format.

Details: None
  • Loading branch information
deepsource-autofix[bot] authored Feb 18, 2025
1 parent 0b5366c commit 14f35a0
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 14f35a0

Please sign in to comment.