mirror of
https://github.com/yudai/gotty.git
synced 2026-02-13 03:44:21 +01:00
server: enable custom listener API
This commit is contained in:
parent
42d8a51a93
commit
1dacb4f91b
2 changed files with 17 additions and 3 deletions
|
|
@ -117,9 +117,13 @@ func (server *Server) Run(ctx context.Context, options ...RunOption) error {
|
|||
log.Printf("Port number configured to `0`, choosing a random port")
|
||||
}
|
||||
hostPort := net.JoinHostPort(server.options.Address, server.options.Port)
|
||||
listener, err := net.Listen("tcp", hostPort)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to listen at `%s`", hostPort)
|
||||
|
||||
listener := opts.listener
|
||||
if listener == nil {
|
||||
listener, err = net.Listen("tcp", hostPort)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to listen at `%s`", hostPort)
|
||||
}
|
||||
}
|
||||
|
||||
scheme := "http"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue