2017-11-20 06:10:04 +01: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.
|
|
|
|
|
2018-01-03 07:04:48 +01:00
|
|
|
package ui
|
2017-11-20 06:10:04 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
2017-11-28 06:30:04 +01:00
|
|
|
|
2018-01-03 07:04:48 +01:00
|
|
|
"github.com/miniflux/miniflux/http/handler"
|
2017-11-20 06:10:04 +01:00
|
|
|
)
|
|
|
|
|
2017-11-28 06:30:04 +01:00
|
|
|
// ShowIcon shows the feed icon.
|
2018-01-03 07:04:48 +01:00
|
|
|
func (c *Controller) ShowIcon(ctx *handler.Context, request *handler.Request, response *handler.Response) {
|
2017-11-22 03:14:45 +01:00
|
|
|
iconID, err := request.IntegerParam("iconID")
|
2017-11-20 06:10:04 +01:00
|
|
|
if err != nil {
|
2017-11-22 03:30:16 +01:00
|
|
|
response.HTML().BadRequest(err)
|
2017-11-20 06:10:04 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-11-28 06:30:04 +01:00
|
|
|
icon, err := c.store.IconByID(iconID)
|
2017-11-20 06:10:04 +01:00
|
|
|
if err != nil {
|
2017-11-22 03:30:16 +01:00
|
|
|
response.HTML().ServerError(err)
|
2017-11-20 06:10:04 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if icon == nil {
|
2017-11-22 03:30:16 +01:00
|
|
|
response.HTML().NotFound()
|
2017-11-20 06:10:04 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
response.Cache(icon.MimeType, icon.Hash, icon.Content, 72*time.Hour)
|
|
|
|
}
|