miniflux-v2/ui/icon.go

34 lines
733 B
Go
Raw Normal View History

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.
package ui
2017-11-20 06:10:04 +01:00
import (
"time"
2017-11-28 06:30:04 +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.
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)
}