mirror of
https://gitee.com/dcren/initializr.git
synced 2025-09-19 01:58:16 +08:00
Fix allowed HTTP methods
This commit reverts to `@RequestMapping` as certain endpoints are invoked with `GET` or `POST`. This is a temporary measure as we need to figure out and properly document allowed methods for all endpoints Closes gh-615
This commit is contained in:
@@ -58,9 +58,9 @@ import org.springframework.http.ResponseEntity.BodyBuilder;
|
|||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.util.DigestUtils;
|
import org.springframework.util.DigestUtils;
|
||||||
import org.springframework.util.StreamUtils;
|
import org.springframework.util.StreamUtils;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.servlet.resource.ResourceUrlProvider;
|
import org.springframework.web.servlet.resource.ResourceUrlProvider;
|
||||||
@@ -107,18 +107,18 @@ public class MainController extends AbstractInitializrController {
|
|||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = "/metadata/config", produces = "application/json")
|
@RequestMapping(path = "/metadata/config", produces = "application/json")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public InitializrMetadata config() {
|
public InitializrMetadata config() {
|
||||||
return metadataProvider.get();
|
return metadataProvider.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/metadata/client")
|
@RequestMapping("/metadata/client")
|
||||||
public String client() {
|
public String client() {
|
||||||
return "redirect:/";
|
return "redirect:/";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = "/", produces = "text/plain")
|
@RequestMapping(path = "/", produces = "text/plain")
|
||||||
public ResponseEntity<String> serviceCapabilitiesText(
|
public ResponseEntity<String> serviceCapabilitiesText(
|
||||||
@RequestHeader(value = HttpHeaders.USER_AGENT, required = false) String userAgent) {
|
@RequestHeader(value = HttpHeaders.USER_AGENT, required = false) String userAgent) {
|
||||||
String appUrl = generateAppUrl();
|
String appUrl = generateAppUrl();
|
||||||
@@ -150,19 +150,19 @@ public class MainController extends AbstractInitializrController {
|
|||||||
return builder.eTag(createUniqueId(content)).body(content);
|
return builder.eTag(createUniqueId(content)).body(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = "/", produces = "application/hal+json")
|
@RequestMapping(path = "/", produces = "application/hal+json")
|
||||||
public ResponseEntity<String> serviceCapabilitiesHal() {
|
public ResponseEntity<String> serviceCapabilitiesHal() {
|
||||||
return serviceCapabilitiesFor(InitializrMetadataVersion.V2_1,
|
return serviceCapabilitiesFor(InitializrMetadataVersion.V2_1,
|
||||||
HAL_JSON_CONTENT_TYPE);
|
HAL_JSON_CONTENT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = "/", produces = { "application/vnd.initializr.v2.1+json",
|
@RequestMapping(path = "/", produces = { "application/vnd.initializr.v2.1+json",
|
||||||
"application/json" })
|
"application/json" })
|
||||||
public ResponseEntity<String> serviceCapabilitiesV21() {
|
public ResponseEntity<String> serviceCapabilitiesV21() {
|
||||||
return serviceCapabilitiesFor(InitializrMetadataVersion.V2_1);
|
return serviceCapabilitiesFor(InitializrMetadataVersion.V2_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = "/", produces = "application/vnd.initializr.v2+json")
|
@RequestMapping(path = "/", produces = "application/vnd.initializr.v2+json")
|
||||||
public ResponseEntity<String> serviceCapabilitiesV2() {
|
public ResponseEntity<String> serviceCapabilitiesV2() {
|
||||||
return serviceCapabilitiesFor(InitializrMetadataVersion.V2);
|
return serviceCapabilitiesFor(InitializrMetadataVersion.V2);
|
||||||
}
|
}
|
||||||
@@ -190,7 +190,7 @@ public class MainController extends AbstractInitializrController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = "/dependencies", produces = {
|
@RequestMapping(path = "/dependencies", produces = {
|
||||||
"application/vnd.initializr.v2.1+json", "application/json" })
|
"application/vnd.initializr.v2.1+json", "application/json" })
|
||||||
public ResponseEntity<String> dependenciesV21(
|
public ResponseEntity<String> dependenciesV21(
|
||||||
@RequestParam(required = false) String bootVersion) {
|
@RequestParam(required = false) String bootVersion) {
|
||||||
@@ -215,25 +215,25 @@ public class MainController extends AbstractInitializrController {
|
|||||||
return (frag, out) -> out.write(this.getLinkTo().apply(frag.execute()));
|
return (frag, out) -> out.write(this.getLinkTo().apply(frag.execute()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = "/", produces = "text/html")
|
@RequestMapping(path = "/", produces = "text/html")
|
||||||
public String home(Map<String, Object> model) {
|
public String home(Map<String, Object> model) {
|
||||||
renderHome(model);
|
renderHome(model);
|
||||||
return "home";
|
return "home";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = { "/spring", "/spring.zip" })
|
@RequestMapping(path = { "/spring", "/spring.zip" })
|
||||||
public String spring() {
|
public String spring() {
|
||||||
String url = metadataProvider.get().createCliDistributionURl("zip");
|
String url = metadataProvider.get().createCliDistributionURl("zip");
|
||||||
return "redirect:" + url;
|
return "redirect:" + url;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = { "/spring.tar.gz", "spring.tgz" })
|
@RequestMapping(path = { "/spring.tar.gz", "spring.tgz" })
|
||||||
public String springTgz() {
|
public String springTgz() {
|
||||||
String url = metadataProvider.get().createCliDistributionURl("tar.gz");
|
String url = metadataProvider.get().createCliDistributionURl("tar.gz");
|
||||||
return "redirect:" + url;
|
return "redirect:" + url;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = { "/pom", "/pom.xml" })
|
@RequestMapping(path = { "/pom", "/pom.xml" })
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity<byte[]> pom(BasicProjectRequest request) {
|
public ResponseEntity<byte[]> pom(BasicProjectRequest request) {
|
||||||
request.setType("maven-build");
|
request.setType("maven-build");
|
||||||
@@ -241,7 +241,7 @@ public class MainController extends AbstractInitializrController {
|
|||||||
return createResponseEntity(mavenPom, "application/octet-stream", "pom.xml");
|
return createResponseEntity(mavenPom, "application/octet-stream", "pom.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = { "/build", "/build.gradle" })
|
@RequestMapping(path = { "/build", "/build.gradle" })
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity<byte[]> gradle(BasicProjectRequest request) {
|
public ResponseEntity<byte[]> gradle(BasicProjectRequest request) {
|
||||||
request.setType("gradle-build");
|
request.setType("gradle-build");
|
||||||
@@ -251,7 +251,7 @@ public class MainController extends AbstractInitializrController {
|
|||||||
"build.gradle");
|
"build.gradle");
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/starter.zip")
|
@RequestMapping("/starter.zip")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity<byte[]> springZip(BasicProjectRequest basicRequest)
|
public ResponseEntity<byte[]> springZip(BasicProjectRequest basicRequest)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
@@ -282,7 +282,7 @@ public class MainController extends AbstractInitializrController {
|
|||||||
return upload(download, dir, generateFileName(request, "zip"), "application/zip");
|
return upload(download, dir, generateFileName(request, "zip"), "application/zip");
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = "/starter.tgz", produces = "application/x-compress")
|
@RequestMapping(path = "/starter.tgz", produces = "application/x-compress")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity<byte[]> springTgz(BasicProjectRequest basicRequest)
|
public ResponseEntity<byte[]> springTgz(BasicProjectRequest basicRequest)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
Reference in New Issue
Block a user