first image \o/
This commit is contained in:
parent
a90bcaaa2d
commit
e9e17ed263
|
@ -26,7 +26,7 @@ func NewWebApp(
|
||||||
indexHandler := NewIndexHandler(entryService)
|
indexHandler := NewIndexHandler(entryService)
|
||||||
listHandler := NewListHandler(entryService)
|
listHandler := NewListHandler(entryService)
|
||||||
entryHandler := NewEntryHandler(entryService, typeRegistry)
|
entryHandler := NewEntryHandler(entryService, typeRegistry)
|
||||||
mediaHandler := NewMediaHandler(entryService)
|
mediaHandler := NewMediaHandler(binService)
|
||||||
rssHandler := NewRSSHandler(entryService)
|
rssHandler := NewRSSHandler(entryService)
|
||||||
loginHandler := NewLoginHandler(authorService)
|
loginHandler := NewLoginHandler(authorService)
|
||||||
editorListHandler := NewEditorListHandler(typeRegistry)
|
editorListHandler := NewEditorListHandler(typeRegistry)
|
||||||
|
@ -47,7 +47,7 @@ func NewWebApp(
|
||||||
app.Get("/", indexHandler.Handle)
|
app.Get("/", indexHandler.Handle)
|
||||||
app.Get("/lists/:list/", listHandler.Handle)
|
app.Get("/lists/:list/", listHandler.Handle)
|
||||||
// Media
|
// Media
|
||||||
app.Get("/media/*filepath", mediaHandler.Handle)
|
app.Get("/media/:id", mediaHandler.Handle)
|
||||||
// RSS
|
// RSS
|
||||||
app.Get("/index.xml", rssHandler.Handle)
|
app.Get("/index.xml", rssHandler.Handle)
|
||||||
// Posts
|
// Posts
|
||||||
|
|
|
@ -7,13 +7,18 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type MediaHandler struct {
|
type MediaHandler struct {
|
||||||
entrySvc *app.EntryService
|
binaryService *app.BinaryService
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMediaHandler(entryService *app.EntryService) *MediaHandler {
|
func NewMediaHandler(binaryService *app.BinaryService) *MediaHandler {
|
||||||
return &MediaHandler{entrySvc: entryService}
|
return &MediaHandler{binaryService: binaryService}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *MediaHandler) Handle(c *fiber.Ctx) error {
|
func (h *MediaHandler) Handle(c *fiber.Ctx) error {
|
||||||
return c.SendString("Hello, Media!")
|
id := c.Params("id")
|
||||||
|
binary, err := h.binaryService.FindById(id)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return c.Send(binary.Data)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
{{define "main"}}
|
{{define "main"}}
|
||||||
|
|
||||||
{{.MetaData.ImageId}}
|
<img src="/media/{{.MetaData.ImageId}}">
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{{.Content}}
|
{{.Content}}
|
||||||
|
|
Loading…
Reference in New Issue