Skip to content

Commit

Permalink
add robots.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxkad committed May 30, 2024
1 parent 5f5623c commit 9775f03
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"bytes"
"context"
"crypto"
_ "embed"
"encoding/hex"
"encoding/json"
"errors"
Expand Down Expand Up @@ -331,6 +332,9 @@ var HeaderXPoweredBy = fmt.Sprintf("go-openbmclapi/%s; url=https://github.com/Li
var accessedTeapotMux sync.RWMutex
var accessedTeapot = make(map[string]struct{})

//go:embed robots.txt
var robotTxtContent string

func (cr *Cluster) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
method := req.Method
u := req.URL
Expand Down Expand Up @@ -401,6 +405,9 @@ func (cr *Cluster) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
cr.handlerAPIv0.ServeHTTP(rw, req)
return
}
case rawpath == "/robots.txt":
http.ServeContent(rw, req, "robots.txt", time.Time{}, strings.NewReader(robotTxtContent))
return
case strings.HasPrefix(rawpath, "/dashboard/"):
if !config.Dashboard.Enable {
http.NotFound(rw, req)
Expand Down
6 changes: 6 additions & 0 deletions robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

User-Agent: *

Disallow: /api/
Disallow: /dashboard/login
Disallow: /dashboard/settings/

0 comments on commit 9775f03

Please sign in to comment.