1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-20 03:17:04 +00:00

fixes, i18n, sitemap generator and new examples

Former-commit-id: 54801dc705ee0fa66232f65063f8a68c9cc31921
This commit is contained in:
Gerasimos (Makis) Maropoulos
2019-12-13 23:06:18 +02:00
parent c66f7a6d21
commit 04477c3e41
58 changed files with 1474 additions and 1311 deletions

View File

@@ -3,6 +3,7 @@ package router
import (
"fmt"
"strings"
"time"
"github.com/kataras/iris/v12/context"
"github.com/kataras/iris/v12/macro"
@@ -44,8 +45,12 @@ type Route struct {
// route, manually or automatic by the framework,
// get the route by `Application#GetRouteByPath(staticSite.RequestPath)`.
StaticSites []context.StaticSite `json:"staticSites"`
topLink *Route
topLink *Route
// Sitemap properties: https://www.sitemaps.org/protocol.html
LastMod time.Time `json:"lastMod,omitempty"`
ChangeFreq string `json:"changeFreq,omitempty"`
Priority float32 `json:"priority,omitempty"`
}
// NewRoute returns a new route based on its method,
@@ -175,6 +180,32 @@ func (r *Route) DeepEqual(other *Route) bool {
return r.Equal(other) && r.tmpl.Src == other.tmpl.Src
}
// SetLastMod sets the date of last modification of the file served by this static GET route.
func (r *Route) SetLastMod(t time.Time) *Route {
r.LastMod = t
return r
}
// SetChangeFreq sets how frequently this static GET route's page is likely to change,
// possible values:
// - "always"
// - "hourly"
// - "daily"
// - "weekly"
// - "monthly"
// - "yearly"
// - "never"
func (r *Route) SetChangeFreq(freq string) *Route {
r.ChangeFreq = freq
return r
}
// SetPriority sets the priority of this static GET route's URL relative to other URLs on your site.
func (r *Route) SetPriority(prio float32) *Route {
r.Priority = prio
return r
}
// Tmpl returns the path template,
// it contains the parsed template
// for the route's path.
@@ -339,3 +370,15 @@ func (rd routeReadOnlyWrapper) MainHandlerName() string {
func (rd routeReadOnlyWrapper) StaticSites() []context.StaticSite {
return rd.Route.StaticSites
}
func (rd routeReadOnlyWrapper) GetLastMod() time.Time {
return rd.Route.LastMod
}
func (rd routeReadOnlyWrapper) GetChangeFreq() string {
return rd.Route.ChangeFreq
}
func (rd routeReadOnlyWrapper) GetPriority() float32 {
return rd.Route.Priority
}