Skip to content

Instantly share code, notes, and snippets.

@oliverpauffley
Created April 20, 2019 09:31
Show Gist options
  • Save oliverpauffley/f15ce43e9e94c78582404e21c8ed0002 to your computer and use it in GitHub Desktop.
Save oliverpauffley/f15ce43e9e94c78582404e21c8ed0002 to your computer and use it in GitHub Desktop.
Handlers-type-embed
type PlayerServer struct {
store PlayerStore
http.Handler
}
func NewPlayerServer(store PlayerStore) *PlayerServer {
p := new(PlayerServer)
p.store = store
router := http.NewServeMux()
router.Handle("/league", http.HandlerFunc(p.leagueHandler))
router.Handle("/players/", http.HandlerFunc(p.playersHandler))
p.Handler = router
return p
}
// Now the ServeHTTP is gone altogether?!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment