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
|
||||
}
|
||||
|
||||
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 {
|
||||
session, err := mgo.Dial(config.MongoDbServer)
|
||||
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() {
|
||||
spaceUrls := readSpaceurl()
|
||||
|
||||
|
|
@ -71,7 +80,8 @@ func loadSpaceData() {
|
|||
if(spaceUrl.Validated && int64(spaceUrl.LastUpdated + 60) < timestamp) {
|
||||
spaceData := SpaceData{}
|
||||
err := getJson(spaceUrl.Url, &spaceData)
|
||||
if(err != nil) {
|
||||
if err != nil
|
||||
{
|
||||
log.Println(spaceUrl.Url)
|
||||
log.Println(err)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -49,6 +49,12 @@ var IndexRoutes = Routes{
|
|||
"/urls/{SharedSecret}",
|
||||
SpaceUrlUpdate,
|
||||
},
|
||||
Route{
|
||||
"SpaceUrlDelete",
|
||||
"DELETE",
|
||||
"/urls/{id}/{SharedSecret}",
|
||||
SpaceUrlDelete,
|
||||
},
|
||||
Route{
|
||||
"RefreshData",
|
||||
"GET",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue