Skip to content

Commit

Permalink
feat(server): add options directly to Start wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
petomalina committed Nov 22, 2021
1 parent 8030b96 commit f965b84
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion examples/grpc-http/main.go
Expand Up @@ -52,7 +52,11 @@ func main() {
logger.Fatal("gw: failed to register: %v", zap.Error(err))
}

srv, err := server.New(os.Getenv("PORT"), time.Second*30)
srv, err := server.New(
os.Getenv("PORT"),
time.Second*30,
server.WithHost("localhost"),
)
if err != nil {
logger.Fatal("xrpc: cannot create server: %v", zap.Error(err))
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/server.go
Expand Up @@ -46,8 +46,8 @@ func New(port string, timeout time.Duration, opts ...Option) (*server, error) {
}

// Start bootstraps a default http server and starts handling requests
func Start(ctx context.Context, port string, timeout time.Duration, handler http.Handler) error {
srv, err := New(port, timeout)
func Start(ctx context.Context, port string, timeout time.Duration, handler http.Handler, opts ...Option) error {
srv, err := New(port, timeout, opts...)
if err != nil {
return err
}
Expand Down

0 comments on commit f965b84

Please sign in to comment.