commit
7efa1e47aa
|
|
@ -361,8 +361,7 @@ public abstract class AbstractWebFluxEndpointHandlerMapping extends RequestMappi
|
|||
return new ResponseEntity<>(response, HttpStatus.OK);
|
||||
}
|
||||
WebEndpointResponse<?> webEndpointResponse = (WebEndpointResponse<?>) response;
|
||||
return new ResponseEntity<>(webEndpointResponse.getBody(),
|
||||
HttpStatus.valueOf(webEndpointResponse.getStatus()));
|
||||
return ResponseEntity.status(webEndpointResponse.getStatus()).body(webEndpointResponse.getBody());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin
|
|||
return result;
|
||||
}
|
||||
WebEndpointResponse<?> response = (WebEndpointResponse<?>) result;
|
||||
return new ResponseEntity<Object>(response.getBody(), HttpStatus.valueOf(response.getStatus()));
|
||||
return ResponseEntity.status(response.getStatus()).body(response.getBody());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -380,6 +380,12 @@ public abstract class AbstractWebEndpointIntegrationTests<T extends Configurable
|
|||
.expectStatus().isOk().expectBody(String.class).isEqualTo("ACTUATOR: true"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void endpointCanProduceAResponseWithACustomStatus() {
|
||||
load((context) -> context.register(CustomResponseStatusEndpointConfiguration.class),
|
||||
(client) -> client.get().uri("/customstatus").exchange().expectStatus().isEqualTo(234));
|
||||
}
|
||||
|
||||
protected abstract int getPort(T context);
|
||||
|
||||
protected void validateErrorBody(WebTestClient.BodyContentSpec body, HttpStatus status, String path,
|
||||
|
|
@ -624,6 +630,17 @@ public abstract class AbstractWebEndpointIntegrationTests<T extends Configurable
|
|||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Import(BaseConfiguration.class)
|
||||
static class CustomResponseStatusEndpointConfiguration {
|
||||
|
||||
@Bean
|
||||
CustomResponseStatusEndpoint customResponseStatusEndpoint() {
|
||||
return new CustomResponseStatusEndpoint();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Endpoint(id = "test")
|
||||
static class TestEndpoint {
|
||||
|
||||
|
|
@ -850,6 +867,16 @@ public abstract class AbstractWebEndpointIntegrationTests<T extends Configurable
|
|||
|
||||
}
|
||||
|
||||
@Endpoint(id = "customstatus")
|
||||
static class CustomResponseStatusEndpoint {
|
||||
|
||||
@ReadOperation
|
||||
WebEndpointResponse<String> read() {
|
||||
return new WebEndpointResponse<>("Custom status", 234);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface EndpointDelegate {
|
||||
|
||||
void write();
|
||||
|
|
|
|||
Loading…
Reference in New Issue