imageproxy

package
v5.100.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2020 License: AGPL-3.0, Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLocalRequestFailed = Error{errors.New("imageproxy.LocalBackend: failed to request proxied image")}
View Source
var ErrNotEnabled = Error{errors.New("imageproxy.ImageProxy: image proxy not enabled")}

Functions

This section is empty.

Types

type AtmosCamoBackend

type AtmosCamoBackend struct {
	// contains filtered or unexported fields
}

func (*AtmosCamoBackend) GetImage

func (backend *AtmosCamoBackend) GetImage(w http.ResponseWriter, r *http.Request, imageURL string)

func (*AtmosCamoBackend) GetImageDirect

func (backend *AtmosCamoBackend) GetImageDirect(imageURL string) (io.ReadCloser, string, error)

type Error

type Error struct {
	// contains filtered or unexported fields
}

type ImageProxy

type ImageProxy struct {
	ConfigService configservice.ConfigService

	HTTPService httpservice.HTTPService

	Logger *mlog.Logger
	// contains filtered or unexported fields
}

An ImageProxy is the public interface for Mattermost's image proxy. An instance of ImageProxy should be created using MakeImageProxy which requires a configService and an HTTPService provided by the server.

func MakeImageProxy

func MakeImageProxy(configService configservice.ConfigService, httpService httpservice.HTTPService, logger *mlog.Logger) *ImageProxy

func (*ImageProxy) Close

func (proxy *ImageProxy) Close()

func (*ImageProxy) GetImage

func (proxy *ImageProxy) GetImage(w http.ResponseWriter, r *http.Request, imageURL string)

GetImage takes an HTTP request for an image and requests that image using the image proxy.

func (*ImageProxy) GetImageDirect

func (proxy *ImageProxy) GetImageDirect(imageURL string) (io.ReadCloser, string, error)

GetImageDirect takes the URL of an image and returns the image along with its content type.

func (*ImageProxy) GetProxiedImageURL

func (proxy *ImageProxy) GetProxiedImageURL(imageURL string) string

GetProxiedImageURL takes the URL of an image and returns a URL that can be used to view that image through the image proxy.

func (*ImageProxy) GetUnproxiedImageURL

func (proxy *ImageProxy) GetUnproxiedImageURL(proxiedURL string) string

GetUnproxiedImageURL takes the URL of an image on the image proxy and returns the original URL of the image.

func (*ImageProxy) OnConfigChange

func (proxy *ImageProxy) OnConfigChange(oldConfig, newConfig *model.Config)

type ImageProxyBackend

type ImageProxyBackend interface {
	// GetImage provides a proxied image in response to an HTTP request.
	GetImage(w http.ResponseWriter, r *http.Request, imageURL string)

	// GetImageDirect returns a proxied image along with its content type.
	GetImageDirect(imageURL string) (io.ReadCloser, string, error)
}

An ImageProxyBackend provides the functionality for different types of image proxies. An ImageProxy will construct the required backend depending on the ImageProxySettings provided by the ConfigService.

type LocalBackend

type LocalBackend struct {
	// contains filtered or unexported fields
}

func (*LocalBackend) GetImage

func (backend *LocalBackend) GetImage(w http.ResponseWriter, r *http.Request, imageURL string)

func (*LocalBackend) GetImageDirect

func (backend *LocalBackend) GetImageDirect(imageURL string) (io.ReadCloser, string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL