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