Skip to content

A simple sitemap.xml middleware for gin-gonic framework.

License

Notifications You must be signed in to change notification settings

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