gaeimage

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2020 License: MIT Imports: 8 Imported by: 0

README

gaeimage

Google App Engine Image Serviceのようなものを2nd genでも利用するために生まれた

アーキテクチャ

v1

変換要求が来る度に画像を生成し、エッジキャッシュに乗せて返す

v2

変換要求が来た時に、変換後ObjectBucketを参照し、そこにすでに画像があれば、それを返す 画像がない場合、画像を生成し、変換後ObjectBucketに保存して、それを返す

Setup

オリジナルの画像が入ったBucketNameにPrefixとして alter- を付けたBucketを作成する。 alter- Bucketに必要であれば Lifecycle を設定して、変換後イメージの削除を行う。

機能

Resize

Pathとして /{bucket}/{object}/=s??? を指定すると画像の長辺を???のサイズにした状態で画像を返す

Example

Limitation
  • Size 0 ~ 2560

Dev

Local GAE Run

go run github.com/sinmetal/gaeimage/app

Deploy

gcloud app deploy app/app.yaml

Documentation

Index

Constants

View Source
const MaxResizeSize = 2560
View Source
const MinResizeSize = 0

Variables

View Source
var InternalError failure.StringCode = "InternalError"
View Source
var InvalidArgument failure.StringCode = "InvalidArgument"
View Source
var NotFound failure.StringCode = "NotFound"

Functions

func ImageHandler

func ImageHandler(w http.ResponseWriter, r *http.Request)

Types

type ImageOption

type ImageOption struct {
	Bucket             string
	Object             string
	Size               int
	CacheControlMaxAge int // Pathから指定はできず、App側で指定する
}

func BuildImageOption

func BuildImageOption(path string) (*ImageOption, error)

BuildImageOption is Request URLからImageOptionを生成する App Engine Image Serviceと同じ雰囲気のURLを利用する時に使う

期待する形式 `/{bucket}/{object}` `/{bucket}/{object}/=sXXX`

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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