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