mirror of
https://github.com/kataras/iris.git
synced 2026-01-10 21:45:57 +00:00
Add notes for the new lead maintainer of the open-source iris project and align with @get-ion/ion by @hiveminded
Former-commit-id: da4f38eb9034daa49446df3ee529423b98f9b331
This commit is contained in:
5
cache/AUTHORS
vendored
Normal file
5
cache/AUTHORS
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
# This is the official list of Iris Cache authors for copyright
|
||||
# purposes.
|
||||
|
||||
Gerasimos Maropoulos <kataras2006@hotmail.com>
|
||||
Bill Qeras, Jr. <hiveminded@tutanota.com>
|
||||
6
cache/LICENSE
vendored
6
cache/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
|
||||
Copyright (c) 2017 The Iris Cache Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
@@ -10,8 +10,8 @@ notice, this list of conditions and the following disclaimer.
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Gerasimos Maropoulos nor the name of his
|
||||
username, kataras, may be used to endorse or promote products derived from
|
||||
* Neither the name of Iris nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
|
||||
7
cache/README.md
vendored
Normal file
7
cache/README.md
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# Cache
|
||||
|
||||
Fast HTTP Cache support for the [iris](https://github.com/kataras/iris) web framework.
|
||||
|
||||
## Table of contents
|
||||
|
||||
* [Simple](_examples/simple/main.go)
|
||||
76
cache/_examples/simple/main.go
vendored
Normal file
76
cache/_examples/simple/main.go
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/context"
|
||||
|
||||
"github.com/kataras/iris/cache"
|
||||
)
|
||||
|
||||
var markdownContents = []byte(`## Hello Markdown
|
||||
|
||||
This is a sample of Markdown contents
|
||||
|
||||
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
All features of Sundown are supported, including:
|
||||
|
||||
* **Compatibility**. The Markdown v1.0.3 test suite passes with
|
||||
the --tidy option. Without --tidy, the differences are
|
||||
mostly in whitespace and entity escaping, where blackfriday is
|
||||
more consistent and cleaner.
|
||||
|
||||
* **Common extensions**, including table support, fenced code
|
||||
blocks, autolinks, strikethroughs, non-strict emphasis, etc.
|
||||
|
||||
* **Safety**. Blackfriday is paranoid when parsing, making it safe
|
||||
to feed untrusted user input without fear of bad things
|
||||
happening. The test suite stress tests this and there are no
|
||||
known inputs that make it crash. If you find one, please let me
|
||||
know and send me the input that does it.
|
||||
|
||||
NOTE: "safety" in this context means *runtime safety only*. In order to
|
||||
protect yourself against JavaScript injection in untrusted content, see
|
||||
[this example](https://github.com/russross/blackfriday#sanitize-untrusted-content).
|
||||
|
||||
* **Fast processing**. It is fast enough to render on-demand in
|
||||
most web applications without having to cache the output.
|
||||
|
||||
* **Routine safety**. You can run multiple parsers in different
|
||||
goroutines without ill effect. There is no dependence on global
|
||||
shared state.
|
||||
|
||||
* **Minimal dependencies**. Blackfriday only depends on standard
|
||||
library packages in Go. The source code is pretty
|
||||
self-contained, so it is easy to add to any project, including
|
||||
Google App Engine projects.
|
||||
|
||||
* **Standards compliant**. Output successfully validates using the
|
||||
W3C validation tool for HTML 4.01 and XHTML 1.0 Transitional.
|
||||
|
||||
[this is a link](https://github.com/kataras/iris) `)
|
||||
|
||||
// Cache should not be used on handlers that contain dynamic data.
|
||||
// Cache is a good and a must-feature on static content, i.e "about page" or for a whole blog site.
|
||||
func main() {
|
||||
app := iris.New()
|
||||
|
||||
app.Get("/", cache.Handler(10*time.Second), writeMarkdown)
|
||||
// saves its content on the first request and serves it instead of re-calculating the content.
|
||||
// After 10 seconds it will be cleared and resetted.
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
}
|
||||
|
||||
func writeMarkdown(ctx context.Context) {
|
||||
// tap multiple times the browser's refresh button and you will
|
||||
// see this println only once every 10 seconds.
|
||||
println("Handler executed. Content refreshed.")
|
||||
|
||||
ctx.Markdown(markdownContents)
|
||||
}
|
||||
23
cache/cache.go
vendored
23
cache/cache.go
vendored
@@ -1,7 +1,3 @@
|
||||
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
/* Package cache provides cache capabilities with rich support of options and rules.
|
||||
|
||||
Example code:
|
||||
@@ -11,8 +7,8 @@ Example code:
|
||||
"time"
|
||||
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/cache"
|
||||
"github.com/kataras/iris/context"
|
||||
"github.com/kataras/iris/cache"
|
||||
)
|
||||
|
||||
func main(){
|
||||
@@ -42,7 +38,7 @@ import (
|
||||
// if the expiration <=2 seconds then expiration is taken by the "cache-control's maxage" header
|
||||
// returns context.Handler, which you can use as your default router or per-route handler
|
||||
//
|
||||
// All type of responses are cached, templates, json, text, anything.
|
||||
// All types of response can be cached, templates, json, text, anything.
|
||||
//
|
||||
// You can add validators with this function.
|
||||
func Cache(bodyHandler context.Handler, expiration time.Duration) *client.Handler {
|
||||
@@ -55,9 +51,9 @@ func Cache(bodyHandler context.Handler, expiration time.Duration) *client.Handle
|
||||
// if the expiration <=2 seconds then expiration is taken by the "cache-control's maxage" header
|
||||
// returns context.Handler, which you can use as your default router or per-route handler
|
||||
//
|
||||
// All type of responses are cached, templates, json, text, anything.
|
||||
// All types of response can be cached, templates, json, text, anything.
|
||||
//
|
||||
// it returns a context.Handler, for more options use the .Cache .
|
||||
// it returns a context.Handler, for more options use the `Cache`
|
||||
func WrapHandler(bodyHandler context.Handler, expiration time.Duration) context.Handler {
|
||||
return Cache(bodyHandler, expiration).ServeHTTP
|
||||
}
|
||||
@@ -69,17 +65,18 @@ func WrapHandler(bodyHandler context.Handler, expiration time.Duration) context.
|
||||
//
|
||||
// It's the same as Cache and WrapHandler but it sets the "bodyHandler" to the next handler in the chain.
|
||||
//
|
||||
// All type of responses are cached, templates, json, text, anything.
|
||||
// All types of response can be cached, templates, json, text, anything.
|
||||
//
|
||||
// it returns a context.Handler, for more options use the .Cache .
|
||||
// it returns a context.Handler which can be used as a middleware, for more options use the `Cache`.
|
||||
//
|
||||
// Examples can be found at: https://github.com/kataras/iris/tree/master/_examples/#caching
|
||||
func Handler(expiration time.Duration) context.Handler {
|
||||
h := WrapHandler(nil, expiration)
|
||||
return h
|
||||
}
|
||||
|
||||
var (
|
||||
// NoCache called when a particular handler is not valid for cache.
|
||||
// If this function called inside a handler then the handler is not cached
|
||||
// even if it's surrounded with the Cache/CacheFunc/CacheRemote wrappers.
|
||||
// NoCache disables the cache for a particular request,
|
||||
// can be used as a middleware or called manually from the handler.
|
||||
NoCache = client.NoCache
|
||||
)
|
||||
|
||||
1
cache/cache_test.go
vendored
1
cache/cache_test.go
vendored
@@ -1,4 +1,3 @@
|
||||
// black-box testing
|
||||
package cache_test
|
||||
|
||||
import (
|
||||
|
||||
4
cache/cfg/cfg.go
vendored
4
cache/cfg/cfg.go
vendored
@@ -1,7 +1,3 @@
|
||||
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cfg
|
||||
|
||||
import "time"
|
||||
|
||||
4
cache/client/client.go
vendored
4
cache/client/client.go
vendored
@@ -1,7 +1,3 @@
|
||||
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package client
|
||||
|
||||
import (
|
||||
|
||||
11
cache/client/handler.go
vendored
11
cache/client/handler.go
vendored
@@ -1,7 +1,3 @@
|
||||
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package client
|
||||
|
||||
import (
|
||||
@@ -31,11 +27,12 @@ type Handler struct {
|
||||
entry *entry.Entry
|
||||
}
|
||||
|
||||
// NewHandler returns a new cached handler
|
||||
// NewHandler returns a new cached handler for the "bodyHandler"
|
||||
// which expires every "expiration".
|
||||
func NewHandler(bodyHandler context.Handler,
|
||||
expireDuration time.Duration) *Handler {
|
||||
expiration time.Duration) *Handler {
|
||||
|
||||
e := entry.NewEntry(expireDuration)
|
||||
e := entry.NewEntry(expiration)
|
||||
|
||||
return &Handler{
|
||||
bodyHandler: bodyHandler,
|
||||
|
||||
4
cache/client/response_recorder.go
vendored
4
cache/client/response_recorder.go
vendored
@@ -1,7 +1,3 @@
|
||||
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package client
|
||||
|
||||
import (
|
||||
|
||||
4
cache/client/rule/chained.go
vendored
4
cache/client/rule/chained.go
vendored
@@ -1,7 +1,3 @@
|
||||
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package rule
|
||||
|
||||
import (
|
||||
|
||||
4
cache/client/rule/conditional.go
vendored
4
cache/client/rule/conditional.go
vendored
@@ -1,7 +1,3 @@
|
||||
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package rule
|
||||
|
||||
import (
|
||||
|
||||
4
cache/client/rule/header.go
vendored
4
cache/client/rule/header.go
vendored
@@ -1,7 +1,3 @@
|
||||
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package rule
|
||||
|
||||
import (
|
||||
|
||||
4
cache/client/rule/not_satisfied.go
vendored
4
cache/client/rule/not_satisfied.go
vendored
@@ -1,7 +1,3 @@
|
||||
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package rule
|
||||
|
||||
import (
|
||||
|
||||
4
cache/client/rule/rule.go
vendored
4
cache/client/rule/rule.go
vendored
@@ -1,7 +1,3 @@
|
||||
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package rule
|
||||
|
||||
import (
|
||||
|
||||
4
cache/client/rule/satisfied.go
vendored
4
cache/client/rule/satisfied.go
vendored
@@ -1,7 +1,3 @@
|
||||
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package rule
|
||||
|
||||
import (
|
||||
|
||||
4
cache/client/rule/validator.go
vendored
4
cache/client/rule/validator.go
vendored
@@ -1,7 +1,3 @@
|
||||
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package rule
|
||||
|
||||
import (
|
||||
|
||||
9
cache/client/ruleset.go
vendored
9
cache/client/ruleset.go
vendored
@@ -1,7 +1,3 @@
|
||||
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package client
|
||||
|
||||
import (
|
||||
@@ -30,9 +26,8 @@ var DefaultRuleSet = rule.Chained(
|
||||
rule.Header(ruleset.NoCacheRule, ruleset.NoCacheRule),
|
||||
)
|
||||
|
||||
// NoCache called when a particular handler is not valid for cache.
|
||||
// If this function called inside a handler then the handler is not cached
|
||||
// even if it's surrounded with the Cache/CacheFunc wrappers.
|
||||
// NoCache disables the cache for a particular request,
|
||||
// can be used as a middleware or called manually from the handler.
|
||||
func NoCache(ctx context.Context) {
|
||||
ctx.Header(cfg.NoCacheHeader, "true")
|
||||
}
|
||||
|
||||
4
cache/client/utils.go
vendored
4
cache/client/utils.go
vendored
@@ -1,7 +1,3 @@
|
||||
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package client
|
||||
|
||||
import (
|
||||
|
||||
4
cache/entry/entry.go
vendored
4
cache/entry/entry.go
vendored
@@ -1,7 +1,3 @@
|
||||
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package entry
|
||||
|
||||
import (
|
||||
|
||||
4
cache/entry/response.go
vendored
4
cache/entry/response.go
vendored
@@ -1,7 +1,3 @@
|
||||
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package entry
|
||||
|
||||
// Response is the cached response will be send to the clients
|
||||
|
||||
4
cache/entry/util.go
vendored
4
cache/entry/util.go
vendored
@@ -1,7 +1,3 @@
|
||||
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package entry
|
||||
|
||||
import (
|
||||
|
||||
4
cache/ruleset/ruleset.go
vendored
4
cache/ruleset/ruleset.go
vendored
@@ -1,7 +1,3 @@
|
||||
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package ruleset provides the basics rules which are being extended by rules.
|
||||
package ruleset
|
||||
|
||||
|
||||
4
cache/uri/uribuilder.go
vendored
4
cache/uri/uribuilder.go
vendored
@@ -1,7 +1,3 @@
|
||||
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package uri
|
||||
|
||||
import (
|
||||
|
||||
Reference in New Issue
Block a user