aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillermo Serrahima <dev@vylion.com>2026-02-19 14:57:38 +0100
committerGuillermo Serrahima <dev@vylion.com>2026-02-19 14:57:38 +0100
commit141deb9759ce743997354395d7906593f838bc4d (patch)
tree0e2e8d3e292f25e048925019296e4af5fef97875
parentaae963a2c3fed674717cb8c5e519da12cc41b5a4 (diff)
downloadllostre-141deb9759ce743997354395d7906593f838bc4d.tar.xz
llostre-141deb9759ce743997354395d7906593f838bc4d.zip
Serving (hardcoded) posts
-rw-r--r--backend/main.go33
1 files changed, 21 insertions, 12 deletions
diff --git a/backend/main.go b/backend/main.go
index 429dd37..24a2973 100644
--- a/backend/main.go
+++ b/backend/main.go
@@ -1,26 +1,35 @@
package main
import (
- "fmt"
- "io"
+ "encoding/json"
+ "llostre/backend/fetchers"
"net/http"
)
-func helloHandler(w http.ResponseWriter, _ *http.Request) {
+func postsHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Content-Type", "application/json")
- w.Write([]byte("Hello, World!"))
-}
-func requestServer() {
- resp, err := http.Get("http://localhost:8080")
- fmt.Println(err)
- defer resp.Body.Close()
- body, err := io.ReadAll(resp.Body)
- fmt.Printf("\nWebserver said: `%s`", string(body))
+ // wip
+ did := "did:plc:hyyqbqqhpxt2bnn7s2e2iuxd"
+ pdsURL := "https://bsky.vylion.com"
+
+ posts, err := fetchers.FetchBlueskyPosts(did, pdsURL)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ jsonData, err := json.Marshal(posts)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.Write(jsonData)
}
func main() {
- http.HandleFunc("/", helloHandler)
+ http.HandleFunc("/api/posts", postsHandler)
http.ListenAndServe(":8080", nil)
}