-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #478 from VerisimilitudeX/deepsource-transform-1e2…
…6cb01 style: format code with Autopep8 and Google Java Format
- Loading branch information
Showing
2 changed files
with
263 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
}; | ||
} | ||
} |
Oops, something went wrong.