imageproxy

package
v5.11.0-rc3+incompatible Latest Latest
Warning

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

Go to latest
Published: May 15, 2019 License: AGPL-3.0, Apache-2.0 Imports: 17 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)

func (*AtmosCamoBackend) GetProxiedImageURL

func (backend *AtmosCamoBackend) GetProxiedImageURL(imageURL string) string

func (*AtmosCamoBackend) GetUnproxiedImageURL

func (backend *AtmosCamoBackend) GetUnproxiedImageURL(proxiedURL string) string

type Error

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

type ImageProxy

type ImageProxy struct {
	ConfigService configservice.ConfigService

	HTTPService httpservice.HTTPService
	// 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) *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)

	// GetProxiedImageURL returns the URL to access a given image through the image proxy, whether the image proxy is
	// running externally or as part of the Mattermost server itself.
	GetProxiedImageURL(imageURL string) string

	// GetUnproxiedImageURL returns the original URL of an image from one that has been directed at the image proxy.
	GetUnproxiedImageURL(proxiedURL string) string
}

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)

func (*LocalBackend) GetProxiedImageURL

func (backend *LocalBackend) GetProxiedImageURL(imageURL string) string

func (*LocalBackend) GetUnproxiedImageURL

func (backend *LocalBackend) GetUnproxiedImageURL(proxiedURL string) string

Jump to

Keyboard shortcuts

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