-
Notifications
You must be signed in to change notification settings - Fork 0
/
RestApi.java
28 lines (24 loc) · 1.11 KB
/
RestApi.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package io.maslick.fluxish;
import org.reactivestreams.Publisher;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
import static org.springframework.http.MediaType.APPLICATION_XML;
import static org.springframework.http.MediaType.APPLICATION_XML_VALUE;
@RestController
@RequestMapping(path = "/xml", produces = APPLICATION_XML_VALUE)
public class RestApi {
@GetMapping(path = "/get")
public Publisher<ResponseEntity> get() {
return Mono.just(ResponseEntity.ok().contentType(APPLICATION_XML).body(new Datta("test")));
}
@PostMapping(path = "/post", consumes = APPLICATION_XML_VALUE)
public Publisher<ResponseEntity<Datta>> post(@RequestBody Datta datus) {
datus.setTitle(datus.getTitle() + "!");
return Mono.just(ResponseEntity.ok().contentType(APPLICATION_XML).body(datus));
}
}