Files
opencloud/vendor/go-micro.dev/v4/api/options.go
dependabot[bot] 50e24b0318 chore(deps): bump go-micro.dev/v4 from 4.10.2 to 4.11.0
Bumps [go-micro.dev/v4](https://github.com/go-micro/go-micro) from 4.10.2 to 4.11.0.
- [Release notes](https://github.com/go-micro/go-micro/releases)
- [Commits](https://github.com/go-micro/go-micro/compare/v4.10.2...v4.11.0)

---
updated-dependencies:
- dependency-name: go-micro.dev/v4
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-08 10:03:51 +02:00

47 lines
903 B
Go

package api
import (
"go-micro.dev/v4/api/router"
registry2 "go-micro.dev/v4/api/router/registry"
"go-micro.dev/v4/client"
"go-micro.dev/v4/registry"
)
func NewOptions(opts ...Option) Options {
options := Options{
Address: ":8080",
}
for _, o := range opts {
o(&options)
}
return options
}
// WithAddress sets the address to listen
func WithAddress(addr string) Option {
return func(o *Options) error {
o.Address = addr
return nil
}
}
// WithRouter sets the router to use e.g static or registry.
func WithRouter(r router.Router) Option {
return func(o *Options) error {
o.Router = r
return nil
}
}
// WithRegistry sets the api's client and router to use registry.
func WithRegistry(r registry.Registry) Option {
return func(o *Options) error {
o.Client = client.NewClient(client.Registry(r))
o.Router = registry2.NewRouter(router.WithRegistry(r))
return nil
}
}