From 18c4be469fab71404072e48d3651dfa3667af3b1 Mon Sep 17 00:00:00 2001 From: Blake Mizerany Date: Wed, 13 Aug 2014 14:09:19 -0700 Subject: [PATCH] move ./http to main --- http/cors.go => cors.go | 4 ++-- main.go | 7 +++---- http/query_params.go => query_params.go | 2 +- http/query_params_test.go => query_params_test.go | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) rename http/cors.go => cors.go (96%) rename http/query_params.go => query_params.go (98%) rename http/query_params_test.go => query_params_test.go (98%) diff --git a/http/cors.go b/cors.go similarity index 96% rename from http/cors.go rename to cors.go index 2729cde57..f23ab6d19 100644 --- a/http/cors.go +++ b/cors.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package http +package main import ( "fmt" @@ -24,7 +24,7 @@ import ( type CORSInfo map[string]bool -func NewCORSInfo(origins []string) (*CORSInfo, error) { +func newCORSInfo(origins []string) (*CORSInfo, error) { // Construct a lookup of all origins. m := make(map[string]bool) for _, v := range origins { diff --git a/main.go b/main.go index e7283bc28..6a2119b46 100644 --- a/main.go +++ b/main.go @@ -11,7 +11,6 @@ import ( "github.com/coreos/etcd/config" "github.com/coreos/etcd/etcd" - ehttp "github.com/coreos/etcd/http" ) func main() { @@ -33,7 +32,7 @@ func main() { } go e.Run() - corsInfo, err := ehttp.NewCORSInfo(config.CorsOrigins) + corsInfo, err := newCORSInfo(config.CorsOrigins) if err != nil { log.Fatal("cors:", err) } @@ -46,7 +45,7 @@ func main() { serve("etcd", config.BindAddr, config.EtcdTLSInfo(), corsInfo, e, readTimeout, writeTimeout) } -func serve(who string, addr string, tinfo *config.TLSInfo, cinfo *ehttp.CORSInfo, handler http.Handler, readTimeout, writeTimeout time.Duration) { +func serve(who string, addr string, tinfo *config.TLSInfo, cinfo *CORSInfo, handler http.Handler, readTimeout, writeTimeout time.Duration) { t, terr := tinfo.ServerConfig() l, err := net.Listen("tcp", addr) if err != nil { @@ -68,7 +67,7 @@ func serve(who string, addr string, tinfo *config.TLSInfo, cinfo *ehttp.CORSInfo log.Fatal("unsupported http scheme", tinfo.Scheme()) } - h := &ehttp.CORSHandler{handler, cinfo} + h := &CORSHandler{handler, cinfo} s := &http.Server{Handler: h, ReadTimeout: readTimeout, WriteTimeout: writeTimeout} log.Fatal(s.Serve(l)) } diff --git a/http/query_params.go b/query_params.go similarity index 98% rename from http/query_params.go rename to query_params.go index 5746d2430..e43ff9bf0 100644 --- a/http/query_params.go +++ b/query_params.go @@ -1,4 +1,4 @@ -package http +package main import ( "net/http" diff --git a/http/query_params_test.go b/query_params_test.go similarity index 98% rename from http/query_params_test.go rename to query_params_test.go index 1920ee134..f2a40dca7 100644 --- a/http/query_params_test.go +++ b/query_params_test.go @@ -1,4 +1,4 @@ -package http +package main import ( "net/http"