-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
main.go
42 lines (31 loc) · 1.07 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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()
// These should be excluded as well
app.Get("/about", handler).ExcludeSitemap()
app.Get("/offline", handler).SetStatusOffline()
return app
}
func handler(ctx iris.Context) { ctx.WriteString(ctx.Path()) }