add delete spaceurl delete route
This commit is contained in:
parent
1ab9d78736
commit
04e022f4d8
3 changed files with 30 additions and 1 deletions
|
|
@ -98,6 +98,19 @@ func readSpaceurl() []SpaceUrl {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func deleteSpaceurl(String id) {
|
||||||
|
session, err := mgo.Dial(config.MongoDbServer)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
defer session.Close()
|
||||||
|
|
||||||
|
session.SetMode(mgo.Monotonic, true)
|
||||||
|
|
||||||
|
c := session.DB(config.MongoDbDatabase).C("spaceurl")
|
||||||
|
c.Remove(bson.M{"_id": id})
|
||||||
|
}
|
||||||
|
|
||||||
func readCalendar() []Calendar {
|
func readCalendar() []Calendar {
|
||||||
session, err := mgo.Dial(config.MongoDbServer)
|
session, err := mgo.Dial(config.MongoDbServer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,15 @@ func SpaceUrlUpdate(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SpaceUrlDelete(w http.ResponseWriter, r *http.Request) {
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
SharedSecret := vars["SharedSecret"]
|
||||||
|
Id := vars["id"]
|
||||||
|
if SharedSecret == config.SharedSecret {
|
||||||
|
deleteSpaceurl(Id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func loadSpaceData() {
|
func loadSpaceData() {
|
||||||
spaceUrls := readSpaceurl()
|
spaceUrls := readSpaceurl()
|
||||||
|
|
||||||
|
|
@ -71,7 +80,8 @@ func loadSpaceData() {
|
||||||
if(spaceUrl.Validated && int64(spaceUrl.LastUpdated + 60) < timestamp) {
|
if(spaceUrl.Validated && int64(spaceUrl.LastUpdated + 60) < timestamp) {
|
||||||
spaceData := SpaceData{}
|
spaceData := SpaceData{}
|
||||||
err := getJson(spaceUrl.Url, &spaceData)
|
err := getJson(spaceUrl.Url, &spaceData)
|
||||||
if(err != nil) {
|
if err != nil
|
||||||
|
{
|
||||||
log.Println(spaceUrl.Url)
|
log.Println(spaceUrl.Url)
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,12 @@ var IndexRoutes = Routes{
|
||||||
"/urls/{SharedSecret}",
|
"/urls/{SharedSecret}",
|
||||||
SpaceUrlUpdate,
|
SpaceUrlUpdate,
|
||||||
},
|
},
|
||||||
|
Route{
|
||||||
|
"SpaceUrlDelete",
|
||||||
|
"DELETE",
|
||||||
|
"/urls/{id}/{SharedSecret}",
|
||||||
|
SpaceUrlDelete,
|
||||||
|
},
|
||||||
Route{
|
Route{
|
||||||
"RefreshData",
|
"RefreshData",
|
||||||
"GET",
|
"GET",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue