fix linting (#4)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -9,10 +9,12 @@ import (
|
||||
"github.com/unistack-org/micro/v3/api/resolver"
|
||||
)
|
||||
|
||||
// Resolver struct
|
||||
type Resolver struct {
|
||||
opts resolver.Options
|
||||
}
|
||||
|
||||
// Resolve func to resolve enndpoint
|
||||
func (r *Resolver) Resolve(req *http.Request, opts ...resolver.ResolveOption) (*resolver.Endpoint, error) {
|
||||
// parse options
|
||||
options := resolver.NewResolveOptions(opts...)
|
||||
@@ -39,6 +41,7 @@ func (r *Resolver) String() string {
|
||||
return "grpc"
|
||||
}
|
||||
|
||||
// NewResolver is used to create new Resolver
|
||||
func NewResolver(opts ...resolver.Option) resolver.Resolver {
|
||||
return &Resolver{opts: resolver.NewOptions(opts...)}
|
||||
}
|
||||
|
@@ -4,11 +4,13 @@ import (
|
||||
"github.com/unistack-org/micro/v3/registry"
|
||||
)
|
||||
|
||||
// Options struct
|
||||
type Options struct {
|
||||
Handler string
|
||||
ServicePrefix string
|
||||
}
|
||||
|
||||
// Option func
|
||||
type Option func(o *Options)
|
||||
|
||||
// WithHandler sets the handler being used
|
||||
@@ -27,7 +29,7 @@ func WithServicePrefix(p string) Option {
|
||||
|
||||
// NewOptions returns new initialised options
|
||||
func NewOptions(opts ...Option) Options {
|
||||
var options Options
|
||||
options := Options{}
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
@@ -51,13 +53,10 @@ func Domain(n string) ResolveOption {
|
||||
|
||||
// NewResolveOptions returns new initialised resolve options
|
||||
func NewResolveOptions(opts ...ResolveOption) ResolveOptions {
|
||||
var options ResolveOptions
|
||||
options := ResolveOptions{Domain: registry.DefaultDomain}
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
if len(options.Domain) == 0 {
|
||||
options.Domain = registry.DefaultDomain
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
|
@@ -7,7 +7,9 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNotFound = errors.New("not found")
|
||||
// ErrNotFound returned when endpoint is not found
|
||||
ErrNotFound = errors.New("not found")
|
||||
// ErrInvalidPath returned on invalid path
|
||||
ErrInvalidPath = errors.New("invalid path")
|
||||
)
|
||||
|
||||
@@ -19,7 +21,7 @@ type Resolver interface {
|
||||
|
||||
// Endpoint is the endpoint for a http request
|
||||
type Endpoint struct {
|
||||
// e.g greeter
|
||||
// Endpoint name e.g greeter
|
||||
Name string
|
||||
// HTTP Host e.g example.com
|
||||
Host string
|
||||
|
@@ -23,6 +23,7 @@ type Options struct {
|
||||
Wrappers []Wrapper
|
||||
}
|
||||
|
||||
// NewOptions returns new Options
|
||||
func NewOptions(opts ...Option) Options {
|
||||
options := Options{}
|
||||
for _, o := range opts {
|
||||
|
Reference in New Issue
Block a user