Class ProjectMetadataController

java.lang.Object
io.spring.initializr.web.controller.AbstractMetadataController
io.spring.initializr.web.controller.ProjectMetadataController

@RestController public class ProjectMetadataController extends AbstractMetadataController
RestController that exposes metadata and service configuration.
Author:
Stephane Nicoll, Moritz Halbritter
  • Field Details

    • HAL_JSON_CONTENT_TYPE

      public static final org.springframework.http.MediaType HAL_JSON_CONTENT_TYPE
      HAL JSON content type.
  • Constructor Details

  • 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, or null for 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, or null for 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, or null for 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 response
      ex - 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 response
      ex - the exception
      Throws:
      IOException - if sending the error fails
    • determineCacheControlFor

      protected org.springframework.http.CacheControl determineCacheControlFor(InitializrMetadata metadata)
      Return the CacheControl response headers to use for the specified metadata. If no cache should be applied CacheControl.empty() can be used.
      Parameters:
      metadata - the metadata about to be exposed
      Returns:
      the Cache-Control headers to use
    • dependenciesFor

      protected org.springframework.http.ResponseEntity<String> dependenciesFor(InitializrMetadataVersion metadataVersion, @Nullable String bootVersion)
      Create the dependencies ResponseEntity for the given version and Spring Boot version.
      Parameters:
      metadataVersion - the metadata version
      bootVersion - 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 capabilities ResponseEntity for the given metadata version and content type.
      Parameters:
      metadataVersion - the metadata version
      contentType - the content type
      Returns:
      the ResponseEntity
    • createMetadataJsonMapper

      protected InitializrMetadataJsonMapper createMetadataJsonMapper(InitializrMetadataVersion metadataVersion)
      Create the JSON mapper for the given metadata version.
      Parameters:
      metadataVersion - the metadata version
      Returns:
      the JSON mapper
    • createDependencyJsonMapper

      protected DependencyMetadataJsonMapper createDependencyJsonMapper(InitializrMetadataVersion metadataVersion)
      Create the JSON mapper for the given metadata version.
      Parameters:
      metadataVersion - the metadata version
      Returns:
      the JSON mapper