proxy

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2018 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Avatar

type Avatar struct {
	Store     AvatarStore
	RoutePath string
	RemarkURL string
}

Avatar provides file-system store and http handler for avatars On user login auth will call Put and it will retrieve and save picture locally.

func (*Avatar) Put

func (p *Avatar) Put(u store.User) (avatarURL string, err error)

Put stores retrieved avatar to StorePath. Gets image from user info. Returns proxied url

func (*Avatar) Routes

func (p *Avatar) Routes(middlewares ...func(http.Handler) http.Handler) (string, chi.Router)

Routes returns auth routes for given provider

type AvatarStore

type AvatarStore interface {
	Put(userID string, reader io.Reader) (avatar string, err error)
	Get(avatar string) (reader io.ReadCloser, size int, err error)
}

AvatarStore defines interface to store and serve avatars

type FSAvatarStore

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

FSAvatarStore implements AvatarStore for local file system

func NewFSAvatarStore

func NewFSAvatarStore(storePath string, resizeLimit int) *FSAvatarStore

NewFSAvatarStore makes file-system avatar store

func (*FSAvatarStore) Get

func (fs *FSAvatarStore) Get(avatar string) (reader io.ReadCloser, size int, err error)

Get avatar reader for avatar id.image

func (*FSAvatarStore) Put

func (fs *FSAvatarStore) Put(userID string, reader io.Reader) (avatar string, err error)

Put avatar for userID to file and return avatar's file name (base), like 12345678.image

type Image

type Image struct {
	RemarkURL string
	RoutePath string
	Enabled   bool
}

Image extracts image src from comment's html and provides proxy for them this is needed to keep remark42 running behind of HTTPS serve all images via https

func (Image) Convert

func (p Image) Convert(commentHTML string) string

Convert all img src links without https to proxied links

func (Image) Routes

func (p Image) Routes() chi.Router

Routes returns router group to respond to proxied request

Jump to

Keyboard shortcuts

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