Provides sitemap.xml support for Gin.
Shamelessly modified clone of gorobots 😬 (originally based on Favicon Middleware for Gin)
Assuming you've already prepared your sitemap.xml file, you can proceed with the steps below.
Download and install the package
go get https://github.com/dragstor/ginsitemap
Add the following line to your import section:
import "github.com/dragstor/ginsitemap"Add the middleware to your router:
r.Use(ginsitemap.New("./path/to/sitemap/sitemap.xml"))package main
import (
"github.com/gin-gonic/gin"
"github.com/dragstor/ginsitemap"
)
func main() {
r := gin.Default()
r.Use(ginsitemap.New("./sitemap.xml"))
r.Run(":8080")
}MIT