Add go.mod and remove /robots.txt
parent
d9117ff753
commit
f7cd306717
@ -0,0 +1,5 @@
|
||||
module git.lcomrade.su/root/lenpaste
|
||||
|
||||
go 1.11
|
||||
|
||||
replace git.lcomrade.su/root/lenpaste/internal => ./internal
|
@ -0,0 +1,2 @@
|
||||
github.com/mattn/go-sqlite3 v1.14.13/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
github.com/yuin/goldmark v1.4.12/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
@ -1,71 +0,0 @@
|
||||
/*
|
||||
Copyright 2021 Leonid Maslakov
|
||||
|
||||
License: GPL-3.0-or-later
|
||||
|
||||
This file is part of Lenpaste.
|
||||
|
||||
Lenpaste is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Lenpaste is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Lenpaste. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package assets
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
const (
|
||||
robotsTxtPath = "./data/robots.txt"
|
||||
)
|
||||
|
||||
//robots.txt
|
||||
func RobotsTxt(rw http.ResponseWriter, req *http.Request) {
|
||||
//Return response
|
||||
rw.Header().Set("Content-Type", "text/plain")
|
||||
|
||||
io.WriteString(rw, robotsTxt)
|
||||
}
|
||||
|
||||
//Load robots.txt
|
||||
func loadRobotsTxt() string {
|
||||
robotsTxt := `
|
||||
User-agent: *
|
||||
Disallow: /`
|
||||
|
||||
//Open file
|
||||
file, err := os.Open(robotsTxtPath)
|
||||
if err != nil {
|
||||
return robotsTxt
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
//Read file
|
||||
fileByte, err := ioutil.ReadAll(file)
|
||||
if err != nil {
|
||||
return robotsTxt
|
||||
}
|
||||
|
||||
return string(fileByte)
|
||||
}
|
||||
|
||||
var robotsTxt string
|
||||
|
||||
//Load
|
||||
func Load() error {
|
||||
robotsTxt = loadRobotsTxt()
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue