func (r *MessageRegistry) WithDefaultBaseUrl(baseUrl string) *MessageRegistry {
	baseUrl = stripTrailingSlash(baseUrl)
	r.defaultBaseUrl = baseUrl
	return r
}
WithDefaultBaseUrl sets the default base URL used when constructing type URLs for
marshalling messages as Any types and converting descriptors to well-known type
descriptions (ptypes). If unspecified, the default base URL will be "type.googleapis.com".
This method is not thread-safe and is intended to be used for one-time initialization
of the registry, before it is published for use by other threads.
package msgregistry
import (
	"fmt"
	"reflect"
	"strings"
	"sync"
	"github.com/golang/protobuf/jsonpb"
	"github.com/golang/protobuf/proto"
	"github.com/golang/protobuf/protoc-gen-go/descriptor"
	"github.com/golang/protobuf/ptypes"
	"github.com/golang/protobuf/ptypes/any"
	"github.com/golang/protobuf/ptypes/wrappers"
	"google.golang.org/genproto/protobuf/api"
	"google.golang.org/genproto/protobuf/ptype"
	"google.golang.org/genproto/protobuf/source_context"
	"github.com/jhump/protoreflect/desc"
	"github.com/jhump/protoreflect/dynamic"
)
const googleApisDomain = "type.googleapis.com"
type ErrUnexpectedType struct {
	URL          string
	ShouldBeEnum bool
}
func (e *ErrUnexpectedType) Error() string {
	msg := "wanted message, got enum"
	if e.ShouldBeEnum {
		msg = "wanted enum, got message"
	}
	return fmt.Sprintf("type for URL %q is the wrong type: %s", e.URL, msg)
}
type MessageRegistry struct {
	resolver       typeResolver
	mf             *dynamic.MessageFactory
	er             *dynamic.ExtensionRegistry
	mu             sync.RWMutex
	types          map[string]desc.Descriptor
	baseUrls       map[string]string
	defaultBaseUrl string
}
func NewMessageRegistryWithDefaults() *MessageRegistry {
	mf := dynamic.NewMessageFactoryWithDefaults()
	return &MessageRegistry{
		mf: mf,
		er: mf.GetExtensionRegistry(),
	}
}
func (r *MessageRegistry) WithFetcher(fetcher TypeFetcher) *MessageRegistry {
	r.resolver = typeResolver{fetcher: fetcher, mr: r}
	return r
}
func (r *MessageRegistry) WithMessageFactory(mf *dynamic.MessageFactory) *MessageRegistry {
	r.mf = mf
	if mf == nil {
		r.er = nil
	} else {
		r.er = mf.GetExtensionRegistry()
	}
	return r
}