Skip to content

dragstor/ginsitemap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

sitemap.xml Gin Middleware

Provides sitemap.xml support for Gin.

Shamelessly modified clone of gorobots 😬 (originally based on Favicon Middleware for Gin)

Usage

Assuming you've already prepared your sitemap.xml file, you can proceed with the steps below.

Step 1

Download and install the package

go get https://github.com/dragstor/ginsitemap

Step 2

Add the following line to your import section:

import "github.com/dragstor/ginsitemap"

Step 3

Add the middleware to your router:

r.Use(ginsitemap.New("./path/to/sitemap/sitemap.xml"))

Example Code

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")
}

License

MIT