mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 10:27:06 +00:00
reorganization of _examples and add some new examples such as iris+groupcache+mysql+docker
Former-commit-id: ed635ee95de7160cde11eaabc0c1dcb0e460a620
This commit is contained in:
38
_examples/routing/sitemap/main.go
Normal file
38
_examples/routing/sitemap/main.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/kataras/iris/v12"
|
||||
)
|
||||
|
||||
const startURL = "http://localhost:8080"
|
||||
|
||||
func main() {
|
||||
app := newApp()
|
||||
|
||||
// http://localhost:8080/sitemap.xml
|
||||
// Lists only online GET static routes.
|
||||
//
|
||||
// Reference: https://www.sitemaps.org/protocol.html
|
||||
app.Listen(":8080", iris.WithSitemap(startURL))
|
||||
}
|
||||
|
||||
func newApp() *iris.Application {
|
||||
app := iris.New()
|
||||
app.Logger().SetLevel("debug")
|
||||
|
||||
lastModified, _ := time.Parse("2006-01-02T15:04:05-07:00", "2019-12-13T21:50:33+02:00")
|
||||
app.Get("/home", handler).SetLastMod(lastModified).SetChangeFreq("hourly").SetPriority(1)
|
||||
app.Get("/articles", handler).SetChangeFreq("daily")
|
||||
app.Get("/path1", handler)
|
||||
app.Get("/path2", handler)
|
||||
|
||||
app.Post("/this-should-not-be-listed", handler)
|
||||
app.Get("/this/{myparam}/should/not/be/listed", handler)
|
||||
app.Get("/this-should-not-be-listed-offline", handler).SetStatusOffline()
|
||||
|
||||
return app
|
||||
}
|
||||
|
||||
func handler(ctx iris.Context) { ctx.WriteString(ctx.Path()) }
|
||||
Reference in New Issue
Block a user