localgaesupport

package module
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: MIT Imports: 9 Imported by: 0

README

Local GAE Support

GAE 2nd genでは、1st genのSDKに含まれていた dev_appserver が使えなくなってしまったため、 app.yamlstatic_dirstatic_files に設定したファイルを開発時にHTTPでアクセスするためには 開発用のハンドラを実装しなければなりません。

dev_appserver which provides static file access in development environoment was included in GAE 1st gen SDK but is not included in GAE 2nd gen. So we have to implement handlers to provide them.

local_gae_supportは、以下のようにハンドラをラップすることで static_dirstatic_files の設定に基づいて、開発環境でのハンドラを定義します。

local_gae_support provides handlers for static_dir or static_files in app.yaml like this:

import "github.com/akm/local_gae_support"
var err error
handler, err = localgaesupport.Static("app.yaml", handler)
if err != nil {
	panic(err)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Static

func Static(appYamlPath string, defaultHandler http.Handler) (http.Handler, error)

Types

type AppYaml

type AppYaml struct {
	Runtime  string          `yaml:"runtime"`
	Service  string          `yaml:"service"`
	Main     string          `yaml:"main"`
	Handlers AppYamlHandlers `yaml:"handlers"`
}

func ParseAppYaml

func ParseAppYaml(path string) (*AppYaml, error)

type AppYamlHandler

type AppYamlHandler struct {
	URL         string            `yaml:"url"`
	StaticFiles string            `yaml:"static_files"`
	StaticDir   string            `yaml:"static_dir"`
	MimeType    string            `yaml:"mime_type"`
	HTTPHeaders map[string]string `yaml:"http_headers"`
	// contains filtered or unexported fields
}

func (*AppYamlHandler) BuildPath

func (h *AppYamlHandler) BuildPath(w http.ResponseWriter, r *http.Request, m1 []string) (string, error)

func (*AppYamlHandler) ProcessHeaders

func (h *AppYamlHandler) ProcessHeaders(w http.ResponseWriter, r *http.Request)

func (*AppYamlHandler) Setup

func (h *AppYamlHandler) Setup() error

type AppYamlHandlers

type AppYamlHandlers []*AppYamlHandler

func (AppYamlHandlers) Each

func (s AppYamlHandlers) Each(f func(*AppYamlHandler) error) error

func (AppYamlHandlers) NewHandler

func (s AppYamlHandlers) NewHandler(defaultHandler http.Handler) http.HandlerFunc

func (AppYamlHandlers) Select

Jump to

Keyboard shortcuts

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