htmlcache

package
v0.0.0-...-800783e Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Copyright 2016 Wenhui Shen <www.webx.top>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 Wenhui Shen <www.webx.top>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 Wenhui Shen <www.webx.top>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HttpCache

func HttpCache(ctx echo.Context, eTag interface{}, etagValidator func(oldEtag, newEtag string) bool) bool

func Output

func Output(content []byte, ctx *X.Context) (err error)

func OutputHTML

func OutputHTML(content []byte, ctx *X.Context, args ...int) (err error)

func OutputJSON

func OutputJSON(content []byte, ctx *X.Context, args ...int) (err error)

func OutputXML

func OutputXML(content []byte, ctx *X.Context, args ...int) (err error)

func RenderHTML

func RenderHTML(ctx *X.Context) (b []byte, err error)

func RenderJSON

func RenderJSON(ctx *X.Context) (b []byte, err error)

func RenderXML

func RenderXML(ctx *X.Context) (b []byte, err error)

Types

type Config

type Config struct {
	HtmlCacheDir   string
	HtmlCacheOn    bool
	HtmlCacheRules map[string]interface{}
	HtmlCacheTime  interface{}
	// contains filtered or unexported fields
}

func (*Config) Expired

func (c *Config) Expired(rule *Rule, ctx echo.Context, saveFile string) (int64, bool)

func (*Config) Middleware

func (c *Config) Middleware() echo.MiddlewareFunc

func (*Config) Read

func (c *Config) Read(ctx echo.Context) bool

func (*Config) Rule

func (c *Config) Rule(rule interface{}) *Rule

func (*Config) SaveFileName

func (c *Config) SaveFileName(rule *Rule, ctx echo.Context) string

func (*Config) Write

func (c *Config) Write(b []byte, ctx echo.Context) bool

type Rule

type Rule struct {
	SaveFile   string                                              //保存名称
	SaveFunc   func(saveFile string, c echo.Context) string        //自定义保存名称
	ExpireTime int                                                 //过期时间(秒)
	ExpireFunc func(saveFile string, c echo.Context) (int64, bool) //判断缓存是否过期
}

Jump to

Keyboard shortcuts

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