Skip to content

Commit

Permalink
[game] provide a way to wrap the muxer provide to a shard config
Browse files Browse the repository at this point in the history
  • Loading branch information
ghthor committed Mar 4, 2015
1 parent 179f18c commit e0e32a1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion game/sim.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ type ShardConfig struct {
// A mux that http server will use. Is provided so the
// user can extend the server with additional routes.
Mux *http.ServeMux

// A handler that will be used instead of the Mux
// when setting the Handler field of the *http.Server.
// If Handler is nil, the Mux will be used instead.
Handler http.Handler
}

func NewSimShard(c ShardConfig) (*http.Server, error) {
Expand Down Expand Up @@ -191,8 +196,13 @@ func NewSimShard(c ShardConfig) (*http.Server, error) {
runningSim,
}, datastore))

defaultHandler := c.Handler
if defaultHandler == nil {
defaultHandler = mux
}

return &http.Server{
Addr: c.LAddr,
Handler: mux,
Handler: defaultHandler,
}, nil
}

0 comments on commit e0e32a1

Please sign in to comment.