Create new, cover and books if don't exists
This commit is contained in:
parent
e7adec0988
commit
ade035eb00
1 changed files with 14 additions and 0 deletions
14
trantor.go
14
trantor.go
|
@ -5,6 +5,7 @@ import (
|
||||||
"labix.org/v2/mgo"
|
"labix.org/v2/mgo"
|
||||||
"labix.org/v2/mgo/bson"
|
"labix.org/v2/mgo/bson"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
type aboutData struct {
|
type aboutData struct {
|
||||||
|
@ -118,6 +119,19 @@ func main() {
|
||||||
userColl := session.DB(DB_NAME).C(USERS_COLL)
|
userColl := session.DB(DB_NAME).C(USERS_COLL)
|
||||||
newColl := session.DB(DB_NAME).C(NEW_BOOKS_COLL)
|
newColl := session.DB(DB_NAME).C(NEW_BOOKS_COLL)
|
||||||
|
|
||||||
|
_, err = os.Stat(BOOKS_PATH)
|
||||||
|
if err != nil {
|
||||||
|
os.Mkdir(BOOKS_PATH, os.ModePerm)
|
||||||
|
}
|
||||||
|
_, err = os.Stat(COVER_PATH)
|
||||||
|
if err != nil {
|
||||||
|
os.Mkdir(COVER_PATH, os.ModePerm)
|
||||||
|
}
|
||||||
|
_, err = os.Stat(NEW_PATH)
|
||||||
|
if err != nil {
|
||||||
|
os.Mkdir(NEW_PATH, os.ModePerm)
|
||||||
|
}
|
||||||
|
|
||||||
http.HandleFunc("/book/", bookHandler(coll))
|
http.HandleFunc("/book/", bookHandler(coll))
|
||||||
http.HandleFunc("/search/", searchHandler(coll))
|
http.HandleFunc("/search/", searchHandler(coll))
|
||||||
http.HandleFunc("/upload/", uploadHandler(newColl))
|
http.HandleFunc("/upload/", uploadHandler(newColl))
|
||||||
|
|
Reference in a new issue