parent
a25d81ce6d
commit
e7781b8f65
12
http.go
12
http.go
|
@ -104,7 +104,7 @@ func Serve(actors map[string]Actor) {
|
|||
totalLines, err := lineCounter(filename)
|
||||
if err != nil {
|
||||
log.Info("Can't read outbox.txt")
|
||||
log.Info(err)
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
if pageStr == "" {
|
||||
|
@ -126,7 +126,7 @@ func Serve(actors map[string]Actor) {
|
|||
lines, err := ReadLines(filename, (page-1)*postsPerPage, page*(postsPerPage+1)-1)
|
||||
if err != nil {
|
||||
log.Info("Can't read outbox file")
|
||||
log.Info(err)
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
responseMap := make(map[string]interface{})
|
||||
|
@ -171,7 +171,7 @@ func Serve(actors map[string]Actor) {
|
|||
response, err = json.Marshal(responseMap)
|
||||
if err != nil {
|
||||
log.Info("can't marshal map to json")
|
||||
log.Info(err)
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ func Serve(actors map[string]Actor) {
|
|||
actor, err := LoadActor(username)
|
||||
// error out if this actor does not exist
|
||||
if err != nil {
|
||||
log.Info("Can't create local actor")
|
||||
log.Errorf("Can't create local actor: %s", err)
|
||||
return
|
||||
}
|
||||
var page int
|
||||
|
@ -314,7 +314,7 @@ func Serve(actors map[string]Actor) {
|
|||
actor, err := LoadActor(username)
|
||||
// error out if this actor does not exist
|
||||
if err != nil {
|
||||
log.Info("Can't create local actor")
|
||||
log.Errorf("Can't create local actor: %s", err)
|
||||
return
|
||||
}
|
||||
post, err := actor.loadItem(hash)
|
||||
|
@ -325,7 +325,7 @@ func Serve(actors map[string]Actor) {
|
|||
}
|
||||
postJSON, err := json.Marshal(post)
|
||||
if err != nil {
|
||||
log.Info("failed to marshal json from item " + hash + " text")
|
||||
log.Errorf("failed to marshal json from item %s text", hash)
|
||||
return
|
||||
}
|
||||
w.Write(postJSON)
|
||||
|
|
|
@ -25,7 +25,7 @@ func NewRemoteActor(iri string) (RemoteActor, error) {
|
|||
info, err := get(iri)
|
||||
if err != nil {
|
||||
log.Info("Couldn't get remote actor information")
|
||||
log.Info(err)
|
||||
log.Error(err)
|
||||
return RemoteActor{}, err
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,6 @@ func (ra RemoteActor) getLatestPosts(number int) (map[string]interface{}, error)
|
|||
}
|
||||
|
||||
func get(iri string) (info map[string]interface{}, err error) {
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
|
||||
req, err := http.NewRequest("GET", iri, buf)
|
||||
|
@ -68,10 +67,9 @@ func get(iri string) (info map[string]interface{}, err error) {
|
|||
req.Header.Add("Accept-Charset", "utf-8")
|
||||
|
||||
resp, err := client.Do(req)
|
||||
|
||||
if err != nil {
|
||||
log.Info("Cannot perform the request")
|
||||
log.Info(err)
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -79,7 +77,7 @@ func get(iri string) (info map[string]interface{}, err error) {
|
|||
|
||||
if !isSuccess(resp.StatusCode) {
|
||||
err = fmt.Errorf("GET request to %s failed (%d): %s\nResponse: %s \nHeaders: %s", iri, resp.StatusCode, resp.Status, FormatJSON(responseData), FormatHeaders(req.Header))
|
||||
log.Info(err)
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -88,7 +86,7 @@ func get(iri string) (info map[string]interface{}, err error) {
|
|||
|
||||
if err != nil {
|
||||
log.Info("something went wrong when unmarshalling the json")
|
||||
log.Info(err)
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
info = e.(map[string]interface{})
|
||||
|
|
Loading…
Reference in New Issue