Commit 8ff2fd4e authored by owlo's avatar owlo

working on posting

parent 3b3a4e6d
......@@ -798,6 +798,42 @@ func main() {
}
})
mux.HandleFunc("/post", func(w http.ResponseWriter, req *http.Request) {
// Before any call to WriteHeader or Write, declare
// the trailers you will set during the HTTP
// response. These three headers are actually sent in
// the trailer.
posts, err := ioutil.ReadDir("tests/posts/")
if err != nil {
fmt.Println(err)
}
numPosts := strconv.Itoa(len(posts))
w.Header().Set("NumBorks", numPosts)
w.WriteHeader(http.StatusOK)
fmt.Println("Signing test json.")
if req.Header.Get("Accept") == "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"" {
fmt.Println("Accept header is correct.")
w.Header().Set("Content-Type", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"")
//w.Header().Set("Authentication", //signature)
var borks []libs.ActorS
for _, v := range posts {
borks = append(borks, updateBork("tests/posts/"+v.Name()))
}
signedContent, err := ioutil.ReadAll(req.Body)
if err != nil {
panic(err)
} else {
output := fmt.Sprint("======================", signedContent, "========================")
fmt.Println(output)
}
upBork(borks)
w.Write(signedContent)
}
})
//CREATE USER
......@@ -810,53 +846,6 @@ func main() {
// the trailer.
// fmt.Println("SOMEONE IS PREPARING TO BORK.")
//defer resp.Body.Close()
//THIS NEEDS TO BE AVAILABLE AS A RESPONSE TO THAT^^
//{
// "subject": "acct:alice@my-example.com",
//
// "links": [
// {
// "rel": "self",
// "type": "application/activity+json",
// "href": "https://my-example.com/actor"
// }
// ]
//}
// object, err := ioutil.ReadAll(req.Body)
// req.Body.Close()
// if err != nil {
// fmt.Println("Error reading reponse.")
// fmt.Println(err)
// }
// beachBall := object
// fmt.Println(beachBall)
// UID := UIDMaker("post")
// validate(UID, object)
//ALSO THE KEY HAS TO BE AVAILBLE TO WEBFINGER LIKE SO
// {
// "@context": "https://www.w3.org/ns/activitystreams",
//
// "id": "https://my-example.com/create-hello-world",
// "type": "Create",
// "actor": "https://my-example.com/actor",
//
// "object": {
// "id": "https://my-example.com/hello-world",
// "type": "Note",
// "published": "2018-06-23T17:17:11Z",
// "attributedTo": "https://my-example.com/actor",
// "inReplyTo": "https://mastodon.social/@Gargron/100254678717223630",
// "content": "<p>Hello world</p>",
// "to": "https://www.w3.org/ns/activitystreams#Public"
// }
// }
// })
// http.ListenAndServe(":443", mux)
// }
mux.HandleFunc("/exampleposter", func(w http.ResponseWriter, req *http.Request) {
// Before any call to WriteHeader or Write, declare
// the trailers you will set during the HTTP
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment