Class ProjectMetadataController
java.lang.Object
io.spring.initializr.web.controller.AbstractMetadataController
io.spring.initializr.web.controller.ProjectMetadataController
RestController that exposes metadata and service configuration.- Author:
- Stephane Nicoll, Moritz Halbritter
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.springframework.http.MediaTypeHAL JSON content type.Fields inherited from class AbstractMetadataController
metadataProvider -
Constructor Summary
ConstructorsConstructorDescriptionProjectMetadataController(InitializrMetadataProvider metadataProvider, DependencyMetadataProvider dependencyMetadataProvider) -
Method Summary
Modifier and TypeMethodDescriptionconfig()Return the metadata configuration.protected DependencyMetadataJsonMappercreateDependencyJsonMapper(InitializrMetadataVersion metadataVersion) Create theJSON mapperfor the given metadata version.protected InitializrMetadataJsonMappercreateMetadataJsonMapper(InitializrMetadataVersion metadataVersion) Create theJSON mapperfor the given metadata version.protected org.springframework.http.ResponseEntity<String> dependenciesFor(InitializrMetadataVersion metadataVersion, @Nullable String bootVersion) Create the dependenciesResponseEntityfor the given version and Spring Boot version.org.springframework.http.ResponseEntity<String> dependenciesV21(String bootVersion) Return the dependencies in v2.1 format.org.springframework.http.ResponseEntity<String> dependenciesV22(String bootVersion) Return the dependencies in v2.2 format.org.springframework.http.ResponseEntity<String> dependenciesV23(String bootVersion) Return the dependencies in v2.3 format.protected org.springframework.http.CacheControldetermineCacheControlFor(InitializrMetadata metadata) Return theCacheControlresponse headers to use for the specifiedmetadata.voidinvalidMetadataRequest(jakarta.servlet.http.HttpServletResponse response, InvalidInitializrMetadataException ex) Handle invalid metadata.voidinvalidProjectRequest(jakarta.servlet.http.HttpServletResponse response, InvalidProjectRequestException ex) Handle an invalid project request.protected org.springframework.http.ResponseEntity<String> serviceCapabilitiesFor(InitializrMetadataVersion metadataVersion, org.springframework.http.MediaType contentType) Create the service capabilitiesResponseEntityfor the given metadata version and content type.org.springframework.http.ResponseEntity<String> Return the capabilities of the service in HAL format.org.springframework.http.ResponseEntity<String> Return the capabilities of the service in v2 format.org.springframework.http.ResponseEntity<String> Return the capabilities of the service in v2.1 format.org.springframework.http.ResponseEntity<String> Return the capabilities of the service in v2.2 format.org.springframework.http.ResponseEntity<String> Return the capabilities of the service in v2.3 format.Methods inherited from class AbstractMetadataController
createUniqueId, generateAppUrl
-
Field Details
-
HAL_JSON_CONTENT_TYPE
public static final org.springframework.http.MediaType HAL_JSON_CONTENT_TYPEHAL JSON content type.
-
-
Constructor Details
-
ProjectMetadataController
public ProjectMetadataController(InitializrMetadataProvider metadataProvider, DependencyMetadataProvider dependencyMetadataProvider)
-
-
Method Details
-
config
@GetMapping(path="/metadata/config", produces="application/json") public InitializrMetadata config()Return the metadata configuration.- Returns:
- the metadata
-
serviceCapabilitiesHal
@GetMapping(path={"/","/metadata/client"}, produces="application/hal+json") public org.springframework.http.ResponseEntity<String> serviceCapabilitiesHal()Return the capabilities of the service in HAL format.- Returns:
- the capabilities
-
serviceCapabilitiesV23
@GetMapping(path={"/","/metadata/client"}, produces="application/vnd.initializr.v2.3+json") public org.springframework.http.ResponseEntity<String> serviceCapabilitiesV23()Return the capabilities of the service in v2.3 format.- Returns:
- the capabilities
-
serviceCapabilitiesV22
@GetMapping(path={"/","/metadata/client"}, produces="application/vnd.initializr.v2.2+json") public org.springframework.http.ResponseEntity<String> serviceCapabilitiesV22()Return the capabilities of the service in v2.2 format.- Returns:
- the capabilities
-
serviceCapabilitiesV21
@GetMapping(path={"/","/metadata/client"}, produces={"application/vnd.initializr.v2.1+json","application/json"}) public org.springframework.http.ResponseEntity<String> serviceCapabilitiesV21()Return the capabilities of the service in v2.1 format.- Returns:
- the capabilities
-
serviceCapabilitiesV2
@GetMapping(path={"/","/metadata/client"}, produces="application/vnd.initializr.v2+json") public org.springframework.http.ResponseEntity<String> serviceCapabilitiesV2()Return the capabilities of the service in v2 format.- Returns:
- the capabilities
-
dependenciesV23
@GetMapping(path="/dependencies", produces="application/vnd.initializr.v2.3+json") public org.springframework.http.ResponseEntity<String> dependenciesV23(@RequestParam(required=false) String bootVersion) Return the dependencies in v2.3 format.- Parameters:
bootVersion- the Spring Boot version, ornullfor the default- Returns:
- the dependencies
-
dependenciesV22
@GetMapping(path="/dependencies", produces="application/vnd.initializr.v2.2+json") public org.springframework.http.ResponseEntity<String> dependenciesV22(@RequestParam(required=false) String bootVersion) Return the dependencies in v2.2 format.- Parameters:
bootVersion- the Spring Boot version, ornullfor the default- Returns:
- the dependencies
-
dependenciesV21
@GetMapping(path="/dependencies", produces={"application/vnd.initializr.v2.1+json","application/json"}) public org.springframework.http.ResponseEntity<String> dependenciesV21(@RequestParam(required=false) String bootVersion) Return the dependencies in v2.1 format.- Parameters:
bootVersion- the Spring Boot version, ornullfor the default- Returns:
- the dependencies
-
invalidMetadataRequest
@ExceptionHandler public void invalidMetadataRequest(jakarta.servlet.http.HttpServletResponse response, InvalidInitializrMetadataException ex) throws IOException Handle invalid metadata.- Parameters:
response- the responseex- the exception- Throws:
IOException- if sending the error fails
-
invalidProjectRequest
@ExceptionHandler public void invalidProjectRequest(jakarta.servlet.http.HttpServletResponse response, InvalidProjectRequestException ex) throws IOException Handle an invalid project request.- Parameters:
response- the responseex- the exception- Throws:
IOException- if sending the error fails
-
determineCacheControlFor
protected org.springframework.http.CacheControl determineCacheControlFor(InitializrMetadata metadata) Return theCacheControlresponse headers to use for the specifiedmetadata. If no cache should be appliedCacheControl.empty()can be used.- Parameters:
metadata- the metadata about to be exposed- Returns:
- the
Cache-Controlheaders to use
-
dependenciesFor
protected org.springframework.http.ResponseEntity<String> dependenciesFor(InitializrMetadataVersion metadataVersion, @Nullable String bootVersion) Create the dependenciesResponseEntityfor the given version and Spring Boot version.- Parameters:
metadataVersion- the metadata versionbootVersion- the Spring Boot version.- Returns:
- the
ResponseEntity
-
serviceCapabilitiesFor
protected org.springframework.http.ResponseEntity<String> serviceCapabilitiesFor(InitializrMetadataVersion metadataVersion, org.springframework.http.MediaType contentType) Create the service capabilitiesResponseEntityfor the given metadata version and content type.- Parameters:
metadataVersion- the metadata versioncontentType- the content type- Returns:
- the
ResponseEntity
-
createMetadataJsonMapper
protected InitializrMetadataJsonMapper createMetadataJsonMapper(InitializrMetadataVersion metadataVersion) Create theJSON mapperfor the given metadata version.- Parameters:
metadataVersion- the metadata version- Returns:
- the JSON mapper
-
createDependencyJsonMapper
protected DependencyMetadataJsonMapper createDependencyJsonMapper(InitializrMetadataVersion metadataVersion) Create theJSON mapperfor the given metadata version.- Parameters:
metadataVersion- the metadata version- Returns:
- the JSON mapper
-