refactor: remove @RequestMapping annotations (#1927)
Co-authored-by: Moderne <team@moderne.io> Co-authored-by: Moderne <team@moderne.io>
This commit is contained in:
committed by
GitHub
parent
cd73feaa0a
commit
961eb345d4
@@ -32,10 +32,10 @@ import org.springframework.context.ApplicationEventPublisherAware;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -71,7 +71,7 @@ public class PropertyPathEndpoint implements ApplicationEventPublisherAware {
|
||||
this.applicationEventPublisher = applicationEventPublisher;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
@PostMapping
|
||||
public Set<String> notifyByPath(@RequestHeader HttpHeaders headers, @RequestBody Map<String, Object> request) {
|
||||
PropertyPathNotification notification = this.extractor.extract(headers, request);
|
||||
if (notification != null) {
|
||||
@@ -94,7 +94,7 @@ public class PropertyPathEndpoint implements ApplicationEventPublisherAware {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
||||
@PostMapping(consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
||||
public Set<String> notifyByForm(@RequestHeader HttpHeaders headers, @RequestParam("path") List<String> request) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String key = "path";
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Application {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
@RequestMapping("/")
|
||||
@GetMapping("/")
|
||||
public String query(@RequestParam("q") String q) {
|
||||
return this.environment.getProperty(q);
|
||||
}
|
||||
|
||||
@@ -35,11 +35,12 @@ import org.springframework.security.rsa.crypto.RsaKeyHolder;
|
||||
import org.springframework.security.rsa.crypto.RsaSecretEncryptor;
|
||||
import org.springframework.util.Base64Utils;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
@@ -73,12 +74,12 @@ public class EncryptionController {
|
||||
this.defaultProfile = defaultProfile;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/key", method = RequestMethod.GET)
|
||||
@GetMapping("/key")
|
||||
public String getPublicKey() {
|
||||
return getPublicKey(defaultApplicationName, defaultProfile);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/key/{name}/{profiles}", method = RequestMethod.GET)
|
||||
@GetMapping("/key/{name}/{profiles}")
|
||||
public String getPublicKey(@PathVariable String name, @PathVariable String profiles) {
|
||||
TextEncryptor encryptor = getEncryptor(name, profiles, "");
|
||||
if (!(encryptor instanceof RsaKeyHolder)) {
|
||||
@@ -87,19 +88,19 @@ public class EncryptionController {
|
||||
return ((RsaKeyHolder) encryptor).getPublicKey();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "encrypt/status", method = RequestMethod.GET)
|
||||
@GetMapping("encrypt/status")
|
||||
public Map<String, Object> status() {
|
||||
TextEncryptor encryptor = getEncryptor(defaultApplicationName, defaultProfile, "");
|
||||
validateEncryptionWeakness(encryptor);
|
||||
return Collections.singletonMap("status", "OK");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "encrypt", method = RequestMethod.POST)
|
||||
@PostMapping("encrypt")
|
||||
public String encrypt(@RequestBody String data, @RequestHeader("Content-Type") MediaType type) {
|
||||
return encrypt(defaultApplicationName, defaultProfile, data, type);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/encrypt/{name}/{profiles}", method = RequestMethod.POST)
|
||||
@PostMapping("/encrypt/{name}/{profiles}")
|
||||
public String encrypt(@PathVariable String name, @PathVariable String profiles, @RequestBody String data,
|
||||
@RequestHeader("Content-Type") MediaType type) {
|
||||
TextEncryptor encryptor = getEncryptor(name, profiles, "");
|
||||
@@ -112,12 +113,12 @@ public class EncryptionController {
|
||||
return encrypted;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "decrypt", method = RequestMethod.POST)
|
||||
@PostMapping("decrypt")
|
||||
public String decrypt(@RequestBody String data, @RequestHeader("Content-Type") MediaType type) {
|
||||
return decrypt(defaultApplicationName, defaultProfile, data, type);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/decrypt/{name}/{profiles}", method = RequestMethod.POST)
|
||||
@PostMapping("/decrypt/{name}/{profiles}")
|
||||
public String decrypt(@PathVariable String name, @PathVariable String profiles, @RequestBody String data,
|
||||
@RequestHeader("Content-Type") MediaType type) {
|
||||
TextEncryptor encryptor = getEncryptor(name, profiles, "");
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
@@ -103,22 +104,22 @@ public class EnvironmentController {
|
||||
this.acceptEmpty = acceptEmpty;
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/{name}/{profiles:.*[^-].*}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@GetMapping(path = "/{name}/{profiles:.*[^-].*}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public Environment defaultLabel(@PathVariable String name, @PathVariable String profiles) {
|
||||
return getEnvironment(name, profiles, null, false);
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/{name}/{profiles:.*[^-].*}", produces = EnvironmentMediaType.V2_JSON)
|
||||
@GetMapping(path = "/{name}/{profiles:.*[^-].*}", produces = EnvironmentMediaType.V2_JSON)
|
||||
public Environment defaultLabelIncludeOrigin(@PathVariable String name, @PathVariable String profiles) {
|
||||
return getEnvironment(name, profiles, null, true);
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/{name}/{profiles}/{label:.*}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@GetMapping(path = "/{name}/{profiles}/{label:.*}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public Environment labelled(@PathVariable String name, @PathVariable String profiles, @PathVariable String label) {
|
||||
return getEnvironment(name, profiles, label, false);
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/{name}/{profiles}/{label:.*}", produces = EnvironmentMediaType.V2_JSON)
|
||||
@GetMapping(path = "/{name}/{profiles}/{label:.*}", produces = EnvironmentMediaType.V2_JSON)
|
||||
public Environment labelledIncludeOrigin(@PathVariable String name, @PathVariable String profiles,
|
||||
@PathVariable String label) {
|
||||
return getEnvironment(name, profiles, label, true);
|
||||
@@ -148,13 +149,13 @@ public class EnvironmentController {
|
||||
return Environment.normalize(part);
|
||||
}
|
||||
|
||||
@RequestMapping("/{name}-{profiles}.properties")
|
||||
@GetMapping("/{name}-{profiles}.properties")
|
||||
public ResponseEntity<String> properties(@PathVariable String name, @PathVariable String profiles,
|
||||
@RequestParam(defaultValue = "true") boolean resolvePlaceholders) throws IOException {
|
||||
return labelledProperties(name, profiles, null, resolvePlaceholders);
|
||||
}
|
||||
|
||||
@RequestMapping("/{label}/{name}-{profiles}.properties")
|
||||
@GetMapping("/{label}/{name}-{profiles}.properties")
|
||||
public ResponseEntity<String> labelledProperties(@PathVariable String name, @PathVariable String profiles,
|
||||
@PathVariable String label, @RequestParam(defaultValue = "true") boolean resolvePlaceholders)
|
||||
throws IOException {
|
||||
@@ -168,13 +169,13 @@ public class EnvironmentController {
|
||||
return getSuccess(propertiesString);
|
||||
}
|
||||
|
||||
@RequestMapping("{name}-{profiles}.json")
|
||||
@GetMapping("{name}-{profiles}.json")
|
||||
public ResponseEntity<String> jsonProperties(@PathVariable String name, @PathVariable String profiles,
|
||||
@RequestParam(defaultValue = "true") boolean resolvePlaceholders) throws Exception {
|
||||
return labelledJsonProperties(name, profiles, null, resolvePlaceholders);
|
||||
}
|
||||
|
||||
@RequestMapping("/{label}/{name}-{profiles}.json")
|
||||
@GetMapping("/{label}/{name}-{profiles}.json")
|
||||
public ResponseEntity<String> labelledJsonProperties(@PathVariable String name, @PathVariable String profiles,
|
||||
@PathVariable String label, @RequestParam(defaultValue = "true") boolean resolvePlaceholders)
|
||||
throws Exception {
|
||||
@@ -199,13 +200,13 @@ public class EnvironmentController {
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
@RequestMapping({ "/{name}-{profiles}.yml", "/{name}-{profiles}.yaml" })
|
||||
@GetMapping({ "/{name}-{profiles}.yml", "/{name}-{profiles}.yaml" })
|
||||
public ResponseEntity<String> yaml(@PathVariable String name, @PathVariable String profiles,
|
||||
@RequestParam(defaultValue = "true") boolean resolvePlaceholders) throws Exception {
|
||||
return labelledYaml(name, profiles, null, resolvePlaceholders);
|
||||
}
|
||||
|
||||
@RequestMapping({ "/{label}/{name}-{profiles}.yml", "/{label}/{name}-{profiles}.yaml" })
|
||||
@GetMapping({ "/{label}/{name}-{profiles}.yml", "/{label}/{name}-{profiles}.yaml" })
|
||||
public ResponseEntity<String> labelledYaml(@PathVariable String name, @PathVariable String profiles,
|
||||
@PathVariable String label, @RequestParam(defaultValue = "true") boolean resolvePlaceholders)
|
||||
throws Exception {
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
@@ -98,7 +99,7 @@ public class ResourceController {
|
||||
this.plainTextEncryptEnabled = plainTextEncryptEnabled;
|
||||
}
|
||||
|
||||
@RequestMapping("/{name}/{profile}/{label}/**")
|
||||
@GetMapping("/{name}/{profile}/{label}/**")
|
||||
public String retrieve(@PathVariable String name, @PathVariable String profile, @PathVariable String label,
|
||||
ServletWebRequest request, @RequestParam(defaultValue = "true") boolean resolvePlaceholders)
|
||||
throws IOException {
|
||||
@@ -106,7 +107,7 @@ public class ResourceController {
|
||||
return retrieve(request, name, profile, label, path, resolvePlaceholders);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{name}/{profile}/{path:.*}", params = "useDefaultLabel")
|
||||
@GetMapping(value = "/{name}/{profile}/{path:.*}", params = "useDefaultLabel")
|
||||
public String retrieveDefault(@PathVariable String name, @PathVariable String profile, @PathVariable String path,
|
||||
ServletWebRequest request, @RequestParam(defaultValue = "true") boolean resolvePlaceholders)
|
||||
throws IOException {
|
||||
@@ -167,14 +168,14 @@ public class ResourceController {
|
||||
return retrieve(null, name, profile, label, path, resolvePlaceholders);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{name}/{profile}/{label}/**", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
@GetMapping(value = "/{name}/{profile}/{label}/**", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public byte[] binary(@PathVariable String name, @PathVariable String profile, @PathVariable String label,
|
||||
ServletWebRequest request) throws IOException {
|
||||
String path = getFilePath(request, name, profile, label);
|
||||
return binary(request, name, profile, label, path);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{name}/{profile}/{path:.*}", params = "useDefaultLabel",
|
||||
@GetMapping(value = "/{name}/{profile}/{path:.*}", params = "useDefaultLabel",
|
||||
produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public byte[] binaryDefault(@PathVariable String name, @PathVariable String profile, @PathVariable String path,
|
||||
ServletWebRequest request) throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user