mirror of
https://github.com/kataras/iris.git
synced 2025-12-22 12:27:02 +00:00
New feature: versioning.Aliases
Thanks @mulyawansentosa and @remopavithran for your donates ❤️
This commit is contained in:
@@ -152,7 +152,7 @@ func newApp() *iris.Application {
|
||||
}
|
||||
|
||||
// wildcard subdomains.
|
||||
wildcardSubdomain := app.Party("*.")
|
||||
wildcardSubdomain := app.WildcardSubdomain()
|
||||
{
|
||||
wildcardSubdomain.Get("/", func(ctx iris.Context) {
|
||||
ctx.Writef("Subdomain can be anything, now you're here from: %s", ctx.Subdomain())
|
||||
|
||||
@@ -82,11 +82,11 @@ func registerGamesRoutes(app *iris.Application) {
|
||||
}
|
||||
|
||||
func registerSubdomains(app *iris.Application) {
|
||||
mysubdomain := app.Party("mysubdomain.")
|
||||
mysubdomain := app.Subdomain("mysubdomain")
|
||||
// http://mysubdomain.myhost.com
|
||||
mysubdomain.Get("/", h)
|
||||
|
||||
willdcardSubdomain := app.Party("*.")
|
||||
willdcardSubdomain := app.WildcardSubdomain()
|
||||
willdcardSubdomain.Get("/", h)
|
||||
willdcardSubdomain.Party("/party").Get("/", h)
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ func main() {
|
||||
adminRoutes.Get("/settings", info)
|
||||
|
||||
// Wildcard/dynamic subdomain
|
||||
dynamicSubdomainRoutes := app.Party("*.")
|
||||
dynamicSubdomainRoutes := app.WildcardSubdomain()
|
||||
|
||||
// GET: http://any_thing_here.localhost:8080
|
||||
dynamicSubdomainRoutes.Get("/", info)
|
||||
|
||||
@@ -33,7 +33,7 @@ func main() {
|
||||
}*/
|
||||
|
||||
// no order, you can register subdomains at the end also.
|
||||
dynamicSubdomains := app.Party("*.")
|
||||
dynamicSubdomains := app.WildcardSubdomain()
|
||||
{
|
||||
dynamicSubdomains.Get("/", dynamicSubdomainHandler)
|
||||
|
||||
|
||||
@@ -45,10 +45,12 @@ func examplePerParty(app *iris.Application) {
|
||||
// You can customize the way a version is extracting
|
||||
// via middleware, for example:
|
||||
// version url parameter, and, if it's missing we default it to "1".
|
||||
usersAPI.Use(func(ctx iris.Context) {
|
||||
versioning.SetVersion(ctx, ctx.URLParamDefault("version", "1"))
|
||||
ctx.Next()
|
||||
})
|
||||
// usersAPI.Use(func(ctx iris.Context) {
|
||||
// versioning.SetVersion(ctx, ctx.URLParamDefault("version", "1"))
|
||||
// ctx.Next()
|
||||
// })
|
||||
// OR:
|
||||
usersAPI.Use(versioning.FromQuery("version", "1"))
|
||||
|
||||
// version 1.
|
||||
usersAPIV1 := versioning.NewGroup(usersAPI, ">= 1, < 2")
|
||||
|
||||
Reference in New Issue
Block a user