github.com/grailbio/base@v0.0.11/config/http/http.go (about) 1 // Copyright 2019 GRAIL, Inc. All rights reserved. 2 // Use of this source code is governed by the Apache 2.0 3 // license that can be found in the LICENSE file. 4 5 // Package http defines profile providers for local HTTP servers. 6 // It is imported for its side effects. 7 package http 8 9 import ( 10 "net/http" 11 12 "github.com/grailbio/base/config" 13 "github.com/grailbio/base/log" 14 ) 15 16 func init() { 17 config.Register("http", func(constr *config.Constructor[config.Nil]) { 18 addr := constr.String("addr", ":3333", "the address used for serving http") 19 constr.Doc = "configure a local HTTP server, using the default http muxer" 20 constr.New = func() (config.Nil, error) { 21 go func() { 22 log.Print("http: serve ", *addr) 23 err := http.ListenAndServe(*addr, nil) 24 log.Error.Print("http: serve ", *addr, ": ", err) 25 }() 26 return nil, nil 27 } 28 }) 29 }