mirror of
https://github.com/go-gitea/gitea.git
synced 2024-09-05 23:34:19 -04:00
Support custom robots.txt
This commit is contained in:
parent
b72d7c201a
commit
1273b3d3a9
@ -364,6 +364,15 @@ func runWeb(*cli.Context) {
|
|||||||
r.Any("/:reponame/*", ignSignInAndCsrf, repo.Http)
|
r.Any("/:reponame/*", ignSignInAndCsrf, repo.Http)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// robots.txt
|
||||||
|
m.Get("/robots.txt", func(ctx *middleware.Context) {
|
||||||
|
if setting.HasRobotsTxt {
|
||||||
|
ctx.ServeFile(path.Join(setting.CustomPath, "robots.txt"))
|
||||||
|
} else {
|
||||||
|
ctx.Error(404)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Not found handler.
|
// Not found handler.
|
||||||
m.NotFound(routers.NotFound)
|
m.NotFound(routers.NotFound)
|
||||||
|
|
||||||
|
@ -108,6 +108,7 @@ var (
|
|||||||
ProdMode bool
|
ProdMode bool
|
||||||
RunUser string
|
RunUser string
|
||||||
IsWindows bool
|
IsWindows bool
|
||||||
|
HasRobotsTxt bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -260,6 +261,8 @@ func NewConfigContext() {
|
|||||||
|
|
||||||
Langs = Cfg.MustValueArray("i18n", "LANGS", ",")
|
Langs = Cfg.MustValueArray("i18n", "LANGS", ",")
|
||||||
Names = Cfg.MustValueArray("i18n", "NAMES", ",")
|
Names = Cfg.MustValueArray("i18n", "NAMES", ",")
|
||||||
|
|
||||||
|
HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt"))
|
||||||
}
|
}
|
||||||
|
|
||||||
var Service struct {
|
var Service struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user