aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorKushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com>2021-11-18 23:25:50 -0400
committerFChannel <>2022-06-19 12:53:29 -0700
commitd5003b51a4ca7ed2c13ffd23b051ea31c8836ba0 (patch)
treea47593f1764f199ce0fdf186aae7d55d2816516a /main.go
parentd1c8716c3e1eebde7e028ff675120854320a714a (diff)
board/thread view; images don't work
Diffstat (limited to 'main.go')
-rw-r--r--main.go24
1 files changed, 13 insertions, 11 deletions
diff --git a/main.go b/main.go
index 02beaf4..2f8131d 100644
--- a/main.go
+++ b/main.go
@@ -116,9 +116,6 @@ func main() {
Views: template,
})
- app.Static("/public", "./public")
- app.Static("/static", "./views")
-
/*
Main actor
*/
@@ -135,7 +132,7 @@ func main() {
Board actor
*/
- app.Get("/:actor", routes.ActorIndex) //OutboxGet)
+ app.Get("/:actor", routes.OutboxGet)
app.Get("/:actor/:post", routes.ActorPostGet)
app.Get("/post", routes.ActorPost)
@@ -234,12 +231,19 @@ func main() {
})
app.Get("/api/media", func(c *fiber.Ctx) error {
- return c.SendString("api media")
+ if c.Query("hash") != "" {
+ return RouteImages(c, c.Query("hash"))
+ }
+
+ return c.SendStatus(404)
})
// 404 handler
app.Use(routes.NotFound)
+ app.Static("/public", "./public")
+ app.Static("/static", "./views")
+
fmt.Println("Mod key: " + config.Key)
PrintAdminAuth()
@@ -979,7 +983,7 @@ func AddInstanceToIndexDB(actor string) error {
return nil
}
-func RouteImages(w http.ResponseWriter, media string) error {
+func RouteImages(ctx *fiber.Ctx, media string) error {
req, err := http.NewRequest("GET", MediaHashs[media], nil)
if err != nil {
return err
@@ -1001,19 +1005,17 @@ func RouteImages(w http.ResponseWriter, media string) error {
return err
}
- _, err = w.Write(fileBytes)
- return err
+ return ctx.Send(fileBytes)
}
body, _ := ioutil.ReadAll(resp.Body)
for name, values := range resp.Header {
for _, value := range values {
- w.Header().Set(name, value)
+ ctx.Append(name, value)
}
}
- _, err = w.Write(body)
- return err
+ return ctx.Send(body)
}
func TemplateFunctions(engine *html.Engine) {