func (c *Client) getLedgerType(domain string) (string, error) {
	jrd, err := c.ResolveWebFingerResource(domain, fmt.Sprintf("%s/vct", domain))
	if err != nil {
		return "", fmt.Errorf("failed to resolve WebFinger resource: %w", err)
	}
	ltRaw, ok := jrd.Properties[command.LedgerType]
	if !ok {
		return "", model.ErrResourceNotFound
	}
	lt, ok := ltRaw.(string)
	if !ok {
		return "", fmt.Errorf("ledger type '%T' is not a string", ltRaw)
	}
	return lt, nil
}
GetLedgerType returns ledger type for domain.
package client
import (
	"encoding/json"
	"errors"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
	"time"
	"github.com/bluele/gcache"
	"github.com/trustbloc/edge-core/pkg/log"
	"github.com/trustbloc/vct/pkg/controller/command"
	"github.com/trustbloc/orb/pkg/discovery/endpoint/restapi"
	"github.com/trustbloc/orb/pkg/webfinger/model"
)
var logger = log.New("webfinger-client")
const (
	defaultCacheLifetime = 300 * time.Second  
	defaultCacheSize     = 100
)
type httpClient interface {
	Do(req *http.Request) (*http.Response, error)
}
type Client struct {
	httpClient httpClient
	cacheLifetime time.Duration
	cacheSize     int
	ledgerTypeCache gcache.Cache
}
func New(opts ...Option) *Client {
	client := &Client{
		httpClient:    &http.Client{},
		cacheLifetime: defaultCacheLifetime,
		cacheSize:     defaultCacheSize,
	}
	for _, opt := range opts {
		opt(client)
	}
	client.ledgerTypeCache = gcache.New(client.cacheSize).
		Expiration(client.cacheLifetime).
		LoaderFunc(func(key interface{}) (interface{}, error) {
			return client.getLedgerType(key.(string))
		}).Build()
	return client
}
func (c *Client) GetLedgerType(domain string) (string, error) {
	ledgerTypeObj, err := c.ledgerTypeCache.Get(domain)
	if err != nil {
		return "", fmt.Errorf("failed to get key[%s] from ledger type cache: %w", domain, err)
	}
	return ledgerTypeObj.(string), nil
}