In the Quick Start paragraph of the spring cloud 3.0.1 reference, it is said that the http service has the following format
/{application}/{profile}[/{label}]
/{application}-{profile}.yml
/{label}/{application}-{profile}.yml
/{application}-{profile}.properties
/{label}/{application}-{profile}.properties
however, as a result of actually checking the code of the project, in org.springframework.cloud.config.server.environment.EnvironmentController
, i confirmed that the application
namging of @PathVariable was expressed as name
.
i attach some code.
@RequestMapping(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)
public Environment defaultLabelIncludeOrigin(@PathVariable String name, @PathVariable String profiles) {
return getEnvironment(name, profiles, null, true);
}
and i think making the following changes is one way to reduce confusion.
@RequestMapping(path = "/{application}/{profiles:.*[^-].*}", produces = MediaType.APPLICATION_JSON_VALUE)
public Environment defaultLabel(@PathVariable String application, @PathVariable String profiles) {
return getEnvironment(application, profiles, null, false);
}
@RequestMapping(path = "/{application}/{profiles:.*[^-].*}", produces = EnvironmentMediaType.V2_JSON)
public Environment defaultLabelIncludeOrigin(@PathVariable String application, @PathVariable String profiles) {
return getEnvironment(application, profiles, null, true);
}
if you don't want to change that part, can you see why you did this ?
Comment From: spencergibb
Those endpoints described are not from the EnvironmentController
, but the ResourceController
.
Comment From: pasudo123
thank you for answer.
something more curious, there are only two endpoints in ResourceController
@RequestMapping("/{name}/{profile}/{label}/**")
public String retrieve(@PathVariable String name, @PathVariable String profile, @PathVariable String label,
ServletWebRequest request, @RequestParam(defaultValue = "true") boolean resolvePlaceholders)
throws IOException {
String path = getFilePath(request, name, profile, label);
return retrieve(request, name, profile, label, path, resolvePlaceholders);
}
///
@RequestMapping(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);
}
i think i should change the name
expression of @PathVariable of ResourceController of application
expression.
doesn't it matter if i don't change it?
Comment From: spencergibb
it doesn't change functionality at all. Feel free to submit a PR.