You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
575 B
26 lines
575 B
package handlers |
|
|
|
import ( |
|
"net/http" |
|
"strings" |
|
) |
|
|
|
// GetRobotsDotTxt returns the contents of our robots.txt. |
|
func (h *Handlers) GetRobotsDotTxt(w http.ResponseWriter, r *http.Request) { |
|
w.Header().Set("Content-Type", "text/plain") |
|
contents := []string{ |
|
"User-agent: *", |
|
"Disallow: /admin", |
|
"Disallow: /api", |
|
} |
|
|
|
if configRepository.GetDisableSearchIndexing() { |
|
contents = append(contents, "Disallow: /") |
|
} |
|
|
|
txt := []byte(strings.Join(contents, "\n")) |
|
|
|
if _, err := w.Write(txt); err != nil { |
|
http.Error(w, err.Error(), http.StatusInternalServerError) |
|
} |
|
}
|
|
|