get alias for pubkey via REST controller

This commit is contained in:
Carsten Otto
2021-11-11 18:58:23 +01:00
parent d6ebfcbb78
commit 4901b70600
9 changed files with 126 additions and 3 deletions

View File

@@ -0,0 +1,23 @@
package de.cotto.lndmanagej.controller;
import de.cotto.lndmanagej.grpc.GrpcNodeInfo;
import de.cotto.lndmanagej.model.Pubkey;
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/")
public class NodeController {
private final GrpcNodeInfo grpcNodeInfo;
public NodeController(GrpcNodeInfo grpcNodeInfo) {
this.grpcNodeInfo = grpcNodeInfo;
}
@GetMapping("/{pubkey}/alias")
public String getAlias(@PathVariable Pubkey pubkey) {
return grpcNodeInfo.getNode(pubkey).alias();
}
}

View File

@@ -0,0 +1,19 @@
package de.cotto.lndmanagej.controller;
import de.cotto.lndmanagej.model.Pubkey;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
import javax.annotation.Nonnull;
@Component
public class PubkeyConverter implements Converter<String, Pubkey> {
public PubkeyConverter() {
// default constructor
}
@Override
public Pubkey convert(@Nonnull String source) {
return Pubkey.create(source);
}
}