1
0
Fork 0
miniflux/ui/icon.go

34 lines
733 B
Go
Raw Normal View History

2017-11-19 21:10:04 -08:00
// Copyright 2017 Frédéric Guillot. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package ui
2017-11-19 21:10:04 -08:00
import (
"time"
2017-11-27 21:30:04 -08:00
"github.com/miniflux/miniflux/http/handler"
2017-11-19 21:10:04 -08:00
)
2017-11-27 21:30:04 -08:00
// ShowIcon shows the feed icon.
func (c *Controller) ShowIcon(ctx *handler.Context, request *handler.Request, response *handler.Response) {
2017-11-21 18:14:45 -08:00
iconID, err := request.IntegerParam("iconID")
2017-11-19 21:10:04 -08:00
if err != nil {
2017-11-21 18:30:16 -08:00
response.HTML().BadRequest(err)
2017-11-19 21:10:04 -08:00
return
}
2017-11-27 21:30:04 -08:00
icon, err := c.store.IconByID(iconID)
2017-11-19 21:10:04 -08:00
if err != nil {
2017-11-21 18:30:16 -08:00
response.HTML().ServerError(err)
2017-11-19 21:10:04 -08:00
return
}
if icon == nil {
2017-11-21 18:30:16 -08:00
response.HTML().NotFound()
2017-11-19 21:10:04 -08:00
return
}
response.Cache(icon.MimeType, icon.Hash, icon.Content, 72*time.Hour)
}