casual http debug
This commit is contained in:
		@@ -4,6 +4,7 @@ import (
 | 
				
			|||||||
	"encoding/json"
 | 
						"encoding/json"
 | 
				
			||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
 | 
						"regexp"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -74,6 +75,8 @@ func (p *PeerCache) LaunchPeerExecution(peerID string, isMySelf bool, dataID str
 | 
				
			|||||||
	if strings.Contains(url, "localhost") || strings.Contains(url, "127.0.0.1") {
 | 
						if strings.Contains(url, "localhost") || strings.Contains(url, "127.0.0.1") {
 | 
				
			||||||
		url = strings.ReplaceAll(url, "localhost", dt.API())
 | 
							url = strings.ReplaceAll(url, "localhost", dt.API())
 | 
				
			||||||
		url = strings.ReplaceAll(url, "127.0.0.1", dt.API())
 | 
							url = strings.ReplaceAll(url, "127.0.0.1", dt.API())
 | 
				
			||||||
 | 
							r := regexp.MustCompile("(:[0-9]{2,4})")
 | 
				
			||||||
 | 
							r.ReplaceAllString(url, ":8080")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	fmt.Println("LaunchPeerExecution AFT", url, dt.API())
 | 
						fmt.Println("LaunchPeerExecution AFT", url, dt.API())
 | 
				
			||||||
	var err error
 | 
						var err error
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,7 +34,8 @@ func (s State) String() string {
 | 
				
			|||||||
		"some things boils in here, i'm probably a teapot", "dead"}[s]
 | 
							"some things boils in here, i'm probably a teapot", "dead"}[s]
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type API struct{}
 | 
					type API struct {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (a *API) GetState() (State, int, error) {
 | 
					func (a *API) GetState() (State, int, error) {
 | 
				
			||||||
	// Check if the database is up
 | 
						// Check if the database is up
 | 
				
			||||||
@@ -78,6 +79,9 @@ func (a *API) CheckRemoteAPIs(urls []string) (State, int, error) {
 | 
				
			|||||||
			return REDUCED_SERVICE, 200, err
 | 
								return REDUCED_SERVICE, 200, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		json.Unmarshal(b, &resp)
 | 
							json.Unmarshal(b, &resp)
 | 
				
			||||||
 | 
							if resp.Data == nil {
 | 
				
			||||||
 | 
								return DEAD, 200, errors.New(url + " -> is DEAD")
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		if resp.Data.Code != 0 {
 | 
							if resp.Data.Code != 0 {
 | 
				
			||||||
			return REDUCED_SERVICE, 200, errors.New(url + " -> " + resp.Error)
 | 
								return REDUCED_SERVICE, 200, errors.New(url + " -> " + resp.Error)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user