Skip to content

Commit 6f2e4e5

Browse files
committed
think about replace open freign
1 parent b43c957 commit 6f2e4e5

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

backend/device-service/src/main/java/org/projectx/device/client/TokenClient.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
import org.springframework.web.bind.annotation.GetMapping;
55
import org.springframework.web.bind.annotation.PathVariable;
66
import org.springframework.web.bind.annotation.PostMapping;
7+
import reactor.core.publisher.Mono;
78

89
@FeignClient("token")
910
public interface TokenClient {
1011

1112
@GetMapping("/tokens/{deviceId}")
12-
TokenResponse getToken(@PathVariable String deviceId);
13+
Mono<TokenResponse> getToken(@PathVariable String deviceId);
1314

1415
@PostMapping("/tokens/{deviceId}")
15-
TokenResponse createToken(@PathVariable String deviceId);
16+
Mono<TokenResponse> createToken(@PathVariable String deviceId);
1617
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.projectx.device.domain;
2+
3+
import feign.Feign;
4+
import org.projectx.device.client.TokenClient;
5+
import org.projectx.device.client.TokenResponse;
6+
import org.springframework.web.bind.annotation.*;
7+
import reactor.core.publisher.Mono;
8+
9+
@RestController
10+
@RequestMapping("/devices")
11+
public class DeviceTokenController {
12+
private final TokenClient tokenClient;
13+
14+
public DeviceTokenController(TokenClient tokenClient) {
15+
this.tokenClient = tokenClient;
16+
}
17+
18+
@GetMapping("/{deviceId}/token")
19+
public Mono<TokenResponse> getDeviceToken(@PathVariable String deviceId) {
20+
return this.tokenClient.getToken(deviceId);
21+
}
22+
23+
@PostMapping("/{deviceId}/token")
24+
public Mono<TokenResponse> createDeviceToken(@PathVariable String deviceId) {
25+
return this.tokenClient.createToken(deviceId);
26+
}
27+
}

0 commit comments

Comments
 (0)