Update to 7.0.8 | iris.UseTemplateFunc -> Read HISTORY.md | Remove vendor folder because of: https://github.com/gavv/httpexpect/pull/34

Read HISTORY.md
This commit is contained in:
Gerasimos (Makis) Maropoulos 2017-01-10 14:21:49 +02:00
parent 893271bf02
commit 053588babd
4 changed files with 108 additions and 54 deletions

View File

@ -2,6 +2,14 @@
**How to upgrade**: remove your `$GOPATH/src/github.com/kataras` folder, open your command-line and execute this command: `go get -u github.com/kataras/iris/iris`.
## 6.0.7 -> 6.0.8
- Add `iris.UseTemplateFunc(functionName string, function interface{})`. You could always set custom template funcs by using each of [template engine's](https://github.com/kataras/go-template) configuration but this function will help newcomers to start creating their custom template funcs.
Example:
- https://github.com/iris-contrib/examples/tree/master/template_funcmap
## 6.0.6 -> 6.0.7
- `iris.Config.DisablePathEscape` -> renamed to `iris.Config.EnablePathEscape`, which defaults to false. Path escape is turned off by-default now,

View File

@ -18,7 +18,7 @@
<br/>
<a href="https://github.com/kataras/iris/blob/master/HISTORY.md"><img src="https://img.shields.io/badge/%20version%20-%206.0.7%20-blue.svg?style=flat-square" alt="CHANGELOG/HISTORY"></a>
<a href="https://github.com/kataras/iris/blob/master/HISTORY.md"><img src="https://img.shields.io/badge/%20version%20-%206.0.8%20-blue.svg?style=flat-square" alt="CHANGELOG/HISTORY"></a>
<a href="https://github.com/iris-contrib/examples"><img src="https://img.shields.io/badge/%20examples-repository-3362c2.svg?style=flat-square" alt="Examples"></a>
@ -943,7 +943,7 @@ I recommend testing your API using this new library, [httpexpect](https://github
Versioning
------------
Current: **v6.0.7**
Current: **v6.0.8**
Older: **[v5/fasthttp](https://github.com/kataras/iris/tree/5.0.0)**

View File

@ -248,6 +248,14 @@ func (ctx *Context) Path() string {
// RequestPath returns the requested path
func (ctx *Context) RequestPath(escape bool) string {
if escape {
// NOTE: for example:
// DecodeURI decodes %2F to '/'
// DecodeQuery decodes any %20 to whitespace
// here we choose to be query-decoded only
// and with context.ParamDecoded the user receives a URI decoded path parameter.
// see https://github.com/iris-contrib/examples/tree/master/named_parameters_pathescape
// and https://github.com/iris-contrib/examples/tree/master/pathescape
return DecodeQuery(ctx.Request.URL.EscapedPath())
}
return ctx.Request.URL.Path

142
iris.go
View File

@ -80,7 +80,7 @@ const (
// IsLongTermSupport flag is true when the below version number is a long-term-support version
IsLongTermSupport = false
// Version is the current version number of the Iris web framework
Version = "6.0.7"
Version = "6.0.8"
banner = ` _____ _
|_ _| (_)
@ -139,82 +139,92 @@ type (
// FrameworkAPI contains the main Iris Public API
FrameworkAPI interface {
MuxAPI
Set(...OptionSetter)
Must(error)
Set(options ...OptionSetter)
Must(err error)
Build()
Serve(net.Listener) error
Listen(string)
ListenTLS(string, string, string)
ListenLETSENCRYPT(string, ...string)
ListenUNIX(string, os.FileMode)
Serve(ln net.Listener) error
Listen(addr string)
ListenTLS(addr string, certFilePath string, keyFilePath string)
ListenLETSENCRYPT(addr string, cacheOptionalStoreFilePath ...string)
ListenUNIX(fileOrAddr string, fileMode os.FileMode)
Close() error
Reserve() error
AcquireCtx(http.ResponseWriter, *http.Request) *Context
ReleaseCtx(*Context)
CheckForUpdates(bool)
UseSessionDB(sessions.Database)
AcquireCtx(w http.ResponseWriter, r *http.Request) *Context
ReleaseCtx(ctx *Context)
CheckForUpdates(check bool)
UseSessionDB(sessDB sessions.Database)
DestroySessionByID(sid string)
DestroyAllSessions()
UseSerializer(string, serializer.Serializer)
UseTemplate(template.Engine) *template.Loader
UsePreRender(PreRender)
UseGlobal(...Handler)
UseGlobalFunc(...HandlerFunc)
Lookup(string) Route
UseSerializer(contentType string, serializerEngine serializer.Serializer)
UsePreRender(prerenderFunc PreRender)
UseTemplateFunc(functionName string, function interface{})
UseTemplate(tmplEngine template.Engine) *template.Loader
UseGlobal(middleware ...Handler)
UseGlobalFunc(middleware ...HandlerFunc)
Lookup(routeName string) Route
Lookups() []Route
Path(string, ...interface{}) string
URL(string, ...interface{}) string
TemplateString(string, interface{}, ...map[string]interface{}) string
TemplateSourceString(string, interface{}) string
SerializeToString(string, interface{}, ...map[string]interface{}) string
Cache(HandlerFunc, time.Duration) HandlerFunc
Path(routeName string, optionalPathParameters ...interface{}) (routePath string)
URL(routeName string, optionalPathParameters ...interface{}) (routeURL string)
TemplateString(file string, binding interface{}, options ...map[string]interface{}) (parsedTemplate string)
TemplateSourceString(src string, binding interface{}) (parsedTemplate string)
SerializeToString(string, interface{}, ...map[string]interface{}) (serializedContent string)
Cache(handlerToCache HandlerFunc, expiration time.Duration) (cachedHandler HandlerFunc)
}
// MuxAPI the visible api for the serveMux
MuxAPI interface {
Party(string, ...HandlerFunc) MuxAPI
Party(reqRelativeRootPath string, middleware ...HandlerFunc) MuxAPI
// middleware serial, appending
Use(...Handler) MuxAPI
UseFunc(...HandlerFunc) MuxAPI
Done(...Handler) MuxAPI
DoneFunc(...HandlerFunc) MuxAPI
Use(middleware ...Handler) MuxAPI
UseFunc(middleware ...HandlerFunc) MuxAPI
Done(middleware ...Handler) MuxAPI
DoneFunc(middleware ...HandlerFunc) MuxAPI
// main handlers
Handle(string, string, ...Handler) RouteNameFunc
HandleFunc(string, string, ...HandlerFunc) RouteNameFunc
API(string, HandlerAPI, ...HandlerFunc)
Handle(method string, reqPath string, middleware ...Handler) RouteNameFunc
HandleFunc(method string, reqPath string, middleware ...HandlerFunc) RouteNameFunc
API(reqRelativeRootPath string, api HandlerAPI, middleware ...HandlerFunc)
// http methods
Get(string, ...HandlerFunc) RouteNameFunc
Post(string, ...HandlerFunc) RouteNameFunc
Put(string, ...HandlerFunc) RouteNameFunc
Delete(string, ...HandlerFunc) RouteNameFunc
Connect(string, ...HandlerFunc) RouteNameFunc
Head(string, ...HandlerFunc) RouteNameFunc
Options(string, ...HandlerFunc) RouteNameFunc
Patch(string, ...HandlerFunc) RouteNameFunc
Trace(string, ...HandlerFunc) RouteNameFunc
Any(string, ...HandlerFunc)
Get(reqRelativePath string, middleware ...HandlerFunc) RouteNameFunc
Post(reqRelativePath string, middleware ...HandlerFunc) RouteNameFunc
Put(reqRelativePath string, middleware ...HandlerFunc) RouteNameFunc
Delete(reqRelativePath string, middleware ...HandlerFunc) RouteNameFunc
Connect(reqRelativePath string, middleware ...HandlerFunc) RouteNameFunc
Head(reqRelativePath string, middleware ...HandlerFunc) RouteNameFunc
Options(reqRelativePath string, middleware ...HandlerFunc) RouteNameFunc
Patch(reqRelativePath string, middleware ...HandlerFunc) RouteNameFunc
Trace(reqRelativePath string, middleware ...HandlerFunc) RouteNameFunc
Any(reqRelativePath string, middleware ...HandlerFunc)
// static content
StaticServe(string, ...string) RouteNameFunc
StaticContent(string, string, []byte) RouteNameFunc
StaticEmbedded(string, string, func(string) ([]byte, error), func() []string) RouteNameFunc
Favicon(string, ...string) RouteNameFunc
StaticServe(systemFilePath string, optionalReqRelativePath ...string) RouteNameFunc
StaticContent(reqRelativePath string, contentType string, contents []byte) RouteNameFunc
StaticEmbedded(reqRelativePath string, contentType string, assets func(string) ([]byte, error), assetsNames func() []string) RouteNameFunc
Favicon(systemFilePath string, optionalReqRelativePath ...string) RouteNameFunc
// static file system
StaticHandler(string, string, bool, bool) HandlerFunc
StaticWeb(string, string) RouteNameFunc
StaticHandler(reqRelativePath string, systemPath string, showList bool, enableGzip bool) HandlerFunc
StaticWeb(reqRelativePath string, systemPath string) RouteNameFunc
// party layout for template engines
Layout(string) MuxAPI
Layout(layoutTemplateFileName string) MuxAPI
// errors
OnError(int, HandlerFunc)
EmitError(int, *Context)
OnError(statusCode int, handler HandlerFunc)
EmitError(statusCode int, ctx *Context)
}
// RouteNameFunc the func returns from the MuxAPi's methods, optionally sets the name of the Route (*route)
RouteNameFunc func(string)
RouteNameFunc func(customRouteName string)
)
// Framework is our God |\| Google.Search('Greek mythology Iris')
@ -884,6 +894,34 @@ func (s *Framework) UsePreRender(pre PreRender) {
s.templates.usePreRender(pre)
}
// UseTemplateFunc sets or replaces a TemplateFunc from the shared available TemplateFuncMap
// defaults are the iris.URL and iris.Path, all the template engines supports the following:
// {{ url "mynamedroute" "pathParameter_ifneeded"} }
// {{ urlpath "mynamedroute" "pathParameter_ifneeded" }}
// {{ render "header.html" }}
// {{ render_r "header.html" }} // partial relative path to current page
// {{ yield }}
// {{ current }}
//
// See more https:/github.com/iris-contrib/examples/tree/master/template_engines/template_funcmap
func UseTemplateFunc(functionName string, function interface{}) {
Default.UseTemplateFunc(functionName, function)
}
// UseTemplateFunc sets or replaces a TemplateFunc from the shared available TemplateFuncMap
// defaults are the iris.URL and iris.Path, all the template engines supports the following:
// {{ url "mynamedroute" "pathParameter_ifneeded"} }
// {{ urlpath "mynamedroute" "pathParameter_ifneeded" }}
// {{ render "header.html" }}
// {{ render_r "header.html" }} // partial relative path to current page
// {{ yield }}
// {{ current }}
//
// See more https:/github.com/iris-contrib/examples/tree/master/template_engines/template_funcmap
func (s *Framework) UseTemplateFunc(functionName string, function interface{}) {
s.templates.SharedFuncs[functionName] = function
}
// UseTemplate adds a template engine to the iris view system
// it does not build/load them yet
func UseTemplate(e template.Engine) *template.Loader {