mirror of
https://github.com/kataras/iris.git
synced 2026-03-10 10:25:57 +00:00
add Context.SetVersion helper
Former-commit-id: 605d6c1e78f73b8f2c89bd2dc7ee23f21551d47b
This commit is contained in:
@@ -81,7 +81,9 @@ type ConfigurationReadOnly interface {
|
||||
// GetLanguageContextKey returns the configuration's LanguageContextKey value,
|
||||
// used for i18n. Defaults to "iris.locale.language".
|
||||
GetLanguageContextKey() string
|
||||
|
||||
// GetVersionContextKey returns the configuration's VersionKey value,
|
||||
// used for API Versioning. Defaults to "iris.api.version".
|
||||
GetVersionContextKey() string
|
||||
// GetViewLayoutContextKey returns the key of the context's user values' key
|
||||
// which is being used to set the template
|
||||
// layout from a middleware or the main handler.
|
||||
|
||||
@@ -424,7 +424,9 @@ type Context interface {
|
||||
// See `GetLocale` too.
|
||||
// Example: https://github.com/kataras/iris/tree/master/_examples/i18n
|
||||
Tr(format string, args ...interface{}) string
|
||||
|
||||
// SetVersion force-sets the API Version integrated with the "iris/versioning" subpackage.
|
||||
// It can be used inside a middleare.
|
||||
SetVersion(constraint string)
|
||||
// +------------------------------------------------------------+
|
||||
// | Headers helpers |
|
||||
// +------------------------------------------------------------+
|
||||
@@ -2025,6 +2027,12 @@ func (ctx *context) Tr(format string, args ...interface{}) string { // other nam
|
||||
return fmt.Sprintf(format, args...)
|
||||
}
|
||||
|
||||
// SetVersion force-sets the API Version integrated with the "iris/versioning" subpackage.
|
||||
// It can be used inside a middleare.
|
||||
func (ctx *context) SetVersion(constraint string) {
|
||||
ctx.Values().Set(ctx.Application().ConfigurationReadOnly().GetVersionContextKey(), constraint)
|
||||
}
|
||||
|
||||
// +------------------------------------------------------------+
|
||||
// | Response Headers helpers |
|
||||
// +------------------------------------------------------------+
|
||||
|
||||
Reference in New Issue
Block a user