mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-30 03:04:38 +01:00
add node details
This commit is contained in:
@@ -26,8 +26,8 @@ public class ChannelDetailsController {
|
||||
}
|
||||
|
||||
@GetMapping("/details")
|
||||
public ChannelDetailsDto getChannelDetails(@PathVariable ChannelId channelId) throws NotFoundException {
|
||||
metrics.mark(MetricRegistry.name(getClass(), "getChannelDetails"));
|
||||
public ChannelDetailsDto getDetails(@PathVariable ChannelId channelId) throws NotFoundException {
|
||||
metrics.mark(MetricRegistry.name(getClass(), "getDetails"));
|
||||
LocalChannel localChannel = channelService.getLocalChannel(channelId).orElse(null);
|
||||
if (localChannel == null) {
|
||||
throw new NotFoundException();
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package de.cotto.lndmanagej.controller;
|
||||
|
||||
import com.codahale.metrics.MetricRegistry;
|
||||
import de.cotto.lndmanagej.metrics.Metrics;
|
||||
import de.cotto.lndmanagej.model.Pubkey;
|
||||
import de.cotto.lndmanagej.service.NodeService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/node/{pubkey}")
|
||||
public class NodeController {
|
||||
private final NodeService nodeService;
|
||||
private final Metrics metrics;
|
||||
|
||||
public NodeController(NodeService nodeService, Metrics metrics) {
|
||||
this.nodeService = nodeService;
|
||||
this.metrics = metrics;
|
||||
}
|
||||
|
||||
@GetMapping("/alias")
|
||||
public String getAlias(Pubkey pubkey) {
|
||||
metrics.mark(MetricRegistry.name(getClass(), "getAlias"));
|
||||
return nodeService.getAlias(pubkey);
|
||||
}
|
||||
|
||||
@GetMapping("/details")
|
||||
public NodeDetailsDto getDetails(@PathVariable Pubkey pubkey) {
|
||||
metrics.mark(MetricRegistry.name(getClass(), "getDetails"));
|
||||
return new NodeDetailsDto(pubkey, getAlias(pubkey));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package de.cotto.lndmanagej.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import de.cotto.lndmanagej.model.Pubkey;
|
||||
|
||||
public record NodeDetailsDto(
|
||||
@JsonSerialize(using = ToStringSerializer.class) Pubkey pubkey,
|
||||
String alias
|
||||
) {
|
||||
}
|
||||
Reference in New Issue
Block a user