Skip to content
Snippets Groups Projects
Commit 7dfbf8ff authored by capossele's avatar capossele
Browse files

:sparkles: adds api /info

parent 2771257e
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ import (
"github.com/iotaledger/goshimmer/plugins/webapi/autopeering"
"github.com/iotaledger/goshimmer/plugins/webapi/data"
"github.com/iotaledger/goshimmer/plugins/webapi/drng"
"github.com/iotaledger/goshimmer/plugins/webapi/info"
"github.com/iotaledger/goshimmer/plugins/webapi/message"
"github.com/iotaledger/goshimmer/plugins/webapi/spammer"
"github.com/iotaledger/goshimmer/plugins/webauth"
......@@ -19,4 +20,5 @@ var PLUGINS = node.Plugins(
drng.PLUGIN,
message.PLUGIN,
autopeering.PLUGIN,
info.PLUGIN,
)
package drng
import (
"encoding/base64"
"encoding/hex"
"errors"
"fmt"
......@@ -20,7 +20,7 @@ func parseCommitteeMembers() (result []ed25519.PublicKey, err error) {
continue
}
pubKey, err := base64.StdEncoding.DecodeString(committeeMember)
pubKey, err := hex.DecodeString(committeeMember)
if err != nil {
return nil, fmt.Errorf("%w: invalid public key: %s", ErrParsingCommitteeMember, err)
}
......
package info
import (
"encoding/hex"
"net/http"
"github.com/iotaledger/goshimmer/plugins/autopeering/local"
"github.com/iotaledger/goshimmer/plugins/webapi"
"github.com/iotaledger/hive.go/node"
"github.com/labstack/echo"
)
var PLUGIN = node.NewPlugin("WebAPI info Endpoint", node.Enabled, configure)
func configure(plugin *node.Plugin) {
webapi.Server.GET("info", getInfo)
}
// getInfo returns the info of the node
func getInfo(c echo.Context) error {
return c.JSON(http.StatusOK, Response{PublicKey: hex.EncodeToString(local.GetInstance().PublicKey().Bytes())})
}
type Response struct {
PublicKey string `json:"publickey,omitempty"`
Error string `json:"error,omitempty"`
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment