Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaley committed Sep 26, 2016
1 parent 96be29e commit 41b90b3
Show file tree
Hide file tree
Showing 38 changed files with 5 additions and 42 deletions.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .travis.yml
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified Makefile
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified glide.lock
100644 → 100755
Empty file.
Empty file modified glide.yaml
100644 → 100755
Empty file.
Empty file modified libreg/README.md
100644 → 100755
Empty file.
Empty file modified libreg/libreg.go
100644 → 100755
Empty file.
Empty file modified libreg/registry/consul/consul.go
100644 → 100755
Empty file.
Empty file modified libreg/registry/mock/mock.go
100644 → 100755
Empty file.
Empty file modified libreg/registry/registry.go
100644 → 100755
Empty file.
Empty file modified rackhd/Dockerfile-endpoint
100644 → 100755
Empty file.
Empty file modified rackhd/Dockerfile-rackhd
100644 → 100755
Empty file.
Empty file modified rackhd/README.md
100644 → 100755
Empty file.
Empty file modified rackhd/cmd/rackhd/main.go
100644 → 100755
Empty file.
Empty file modified rackhd/cmd/utils/api/api.go
100644 → 100755
Empty file.
Empty file modified rackhd/cmd/utils/main.go
100644 → 100755
Empty file.
Empty file modified rackhd/docker-compose-rackhd.yaml
100644 → 100755
Empty file.
47 changes: 5 additions & 42 deletions rackhd/proxy/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,8 @@ func (p *Server) HandleNodes(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(fmt.Sprintf("%s", err)))
return
}
if (r.Method == "") || (r.Method == "GET") {
cr, _ := p.GetResp(r, addrMap)
p.RespCheck(w, cr)
}
if r.Method == "POST" {
cr, _ := p.PostResp(r, addrMap)
p.RespCheck(w, cr)
}
cr, _ := p.GetResp(r, addrMap)
p.RespCheck(w, cr)
}

// GetResp makes channels for the response and errors from http.Get.
Expand All @@ -86,22 +80,22 @@ func (p *Server) GetResp(r *http.Request, addrs map[string]struct{}) (chan *Resp

for entry := range addrs {
p.wg.Add(1)
fmt.Printf("Entry => %+v\n", entry)
fmt.Printf("Entry => %+v\n\n", entry)
go func(entry string, r *http.Request) {
defer p.wg.Done()
req, err := NewRequest(r, entry)
if err != nil {
log.Printf("Error creating request => %s\n", err)
return
}
fmt.Printf("Request URL String in => %+v\n", r.URL.String())
fmt.Printf("Request => \n%+v\n\n", req)
client := cleanhttp.DefaultClient()
respGet, err := client.Do(req)
if err != nil {
errs <- fmt.Errorf("Could not send HTTP Get request to %s => %s\n", req.URL.String(), err)
return
}
fmt.Printf("RESP => %+v\n\n", respGet.Request.URL.String())
fmt.Printf("RESP URL => \n%+v\n\n\n", respGet.Body)
responseCopy, err := NewResponse(respGet)
if err != nil {
log.Printf("Error copying response => %s\n", err)
Expand All @@ -115,37 +109,6 @@ func (p *Server) GetResp(r *http.Request, addrs map[string]struct{}) (chan *Resp
return cr, errs
}

// PostResp sends a POST request to each address
func (p *Server) PostResp(r *http.Request, addrs map[string]struct{}) (chan *Response, chan error) {
cr := make(chan *Response, len(addrs))
errs := make(chan error, len(addrs))
defer close(cr)
defer close(errs)
for entry := range addrs {
p.wg.Add(1)
go func(entry string) {
defer p.wg.Done()
r.URL.Host = entry
r.URL.Scheme = "http"
fmt.Printf("url string %s\n", r.URL.String())
respPost, err := http.Post(r.URL.String(), "application/json", r.Body)
if err != nil {
errs <- fmt.Errorf("Could not send HTTP Post request to %s => %s\n", r.URL.String(), err)
return
}
responseCopy, err := NewResponse(respPost)
if err != nil {
log.Printf("Error copying response => %s\n", err)
return
}
cr <- responseCopy
respPost.Body.Close()
}(entry)
}
p.wg.Wait()
return cr, errs
}

// GetAddresses decides from where to retrieve the addresses
func (p *Server) GetAddresses(w http.ResponseWriter, r *http.Request) (map[string]struct{}, error) {
if err := r.ParseForm(); err != nil {
Expand Down
File renamed without changes.
Empty file modified rackhd/watcher/watcher_suite_test.go
100644 → 100755
Empty file.
Empty file modified rackhd/watcher/watcher_test.go
100644 → 100755
Empty file.
Empty file modified registry/Dockerfile-registry
100644 → 100755
Empty file.
Empty file modified registry/Dockerfile-ssdp
100644 → 100755
Empty file.
Empty file modified registry/LICENSE
100644 → 100755
Empty file.
Empty file modified registry/README.md
100644 → 100755
Empty file.
Empty file modified registry/cmd/registry/main.go
100644 → 100755
Empty file.
Empty file modified registry/cmd/ssdpspoofer/main.go
100644 → 100755
Empty file.
Empty file modified registry/cmd/ssdpspoofer/ssdpSpoof.json
100644 → 100755
Empty file.
Empty file modified registry/docker-compose-registry.yaml
100644 → 100755
Empty file.
Empty file modified registry/registry.go
100644 → 100755
Empty file.
Empty file modified registry/registry.json
100644 → 100755
Empty file.
Empty file modified registry/registry_suite_test.go
100644 → 100755
Empty file.
Empty file modified registry/registry_test.go
100644 → 100755
Empty file.
Empty file modified registry/utils/ClearConsul/main.go
100644 → 100755
Empty file.
Empty file modified registry/utils/ssdpSpoofer/main.go
100644 → 100755
Empty file.
Empty file modified registry/utils/ssdpSpoofer/ssdpSpoof.json
100644 → 100755
Empty file.

0 comments on commit 41b90b3

Please sign in to comment.