+27
-4
cmd/feedweb/main.go
+27
-4
cmd/feedweb/main.go
···
5
"net/http"
6
7
appbsky "github.com/bluesky-social/indigo/api/bsky"
8
"github.com/edavis/bsky-feeds/pkg/feeds"
9
"github.com/edavis/bsky-feeds/pkg/mostliked"
10
"github.com/labstack/echo/v4"
···
24
return t
25
}
26
27
func getFeedSkeleton(c echo.Context) error {
28
var req SkeletonRequest
29
if err := c.Bind(&req); err != nil {
30
return c.String(http.StatusBadRequest, "bad request")
31
}
32
33
-
generators := FeedLookup{
34
-
"at://did:plc:4nsduwlpivpuur4mqkbfvm6a/app.bsky.feed.generator/most-liked": mostliked.Feed,
35
-
}
36
-
37
params := feeds.FeedgenParams{
38
Feed: req.Feed,
39
Limit: req.Limit,
···
48
return c.JSON(http.StatusOK, feed)
49
}
50
51
func main() {
52
e := echo.New()
53
e.Use(middleware.Logger())
54
e.Use(middleware.Recover())
55
e.GET("/.well-known/did.json", didDoc)
56
e.GET("/xrpc/app.bsky.feed.getFeedSkeleton", getFeedSkeleton)
57
e.Logger.Fatal(e.Start(":5000"))
58
}
···
5
"net/http"
6
7
appbsky "github.com/bluesky-social/indigo/api/bsky"
8
+
"github.com/bluesky-social/indigo/atproto/syntax"
9
"github.com/edavis/bsky-feeds/pkg/feeds"
10
"github.com/edavis/bsky-feeds/pkg/mostliked"
11
"github.com/labstack/echo/v4"
···
25
return t
26
}
27
28
+
var generators = FeedLookup{
29
+
"at://did:plc:4nsduwlpivpuur4mqkbfvm6a/app.bsky.feed.generator/most-liked": mostliked.Feed,
30
+
}
31
+
32
func getFeedSkeleton(c echo.Context) error {
33
var req SkeletonRequest
34
if err := c.Bind(&req); err != nil {
35
return c.String(http.StatusBadRequest, "bad request")
36
}
37
38
params := feeds.FeedgenParams{
39
Feed: req.Feed,
40
Limit: req.Limit,
···
49
return c.JSON(http.StatusOK, feed)
50
}
51
52
+
func describeFeedGenerator(c echo.Context) error {
53
+
type gen struct {
54
+
DID string `json:"did"`
55
+
Feeds []syntax.ATURI `json:"feeds"`
56
+
}
57
+
58
+
out := gen{
59
+
DID: `https://` + NgrokHostname,
60
+
}
61
+
62
+
for feedUri, _ := range generators {
63
+
aturi, err := syntax.ParseATURI(feedUri)
64
+
if err != nil {
65
+
continue
66
+
}
67
+
out.Feeds = append(out.Feeds, aturi)
68
+
}
69
+
70
+
return c.JSON(http.StatusOK, out)
71
+
}
72
+
73
func main() {
74
e := echo.New()
75
e.Use(middleware.Logger())
76
e.Use(middleware.Recover())
77
e.GET("/.well-known/did.json", didDoc)
78
e.GET("/xrpc/app.bsky.feed.getFeedSkeleton", getFeedSkeleton)
79
+
e.GET("/xrpc/app.bsky.feed.describeFeedGenerator", describeFeedGenerator)
80
e.Logger.Fatal(e.Start(":5000"))
81
}