now it looks fantastic. Nothing under!
This commit is contained in:
1 parent
a72347d1e3
commit
59813e906e
15 files changed
+130
-16
No files matched your search
@@ -6,6 +6,7 @@ import (
|
||||
"errors"
|
||||
"github.com/gorilla/mux"
|
||||
"labix.org/v2/mgo"
|
||||
"labix.org/v2/mgo/bson"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
@@ -141,6 +142,22 @@ func getDocumentByIndex(w http.ResponseWriter, request *http.Request) (interface
|
||||
return vb.GetDocumentByIndex(index, nil)
|
||||
}
|
||||
|
||||
func getDocumentById(w http.ResponseWriter, request *http.Request) (interface{}, error) {
|
||||
vb, err := GetVultureBackend(request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
vars := mux.Vars(request)
|
||||
id, ok := vars["id"]
|
||||
if !ok {
|
||||
return nil, errors.New("id field not specified")
|
||||
}
|
||||
if !bson.IsObjectIdHex(id) {
|
||||
return nil, errors.New("id field is not an object id")
|
||||
}
|
||||
return vb.GetDocumentByIndex(0, bson.M{"_id": bson.ObjectIdHex(id)})
|
||||
}
|
||||
|
||||
func getDocumentByQueryAndIndex(w http.ResponseWriter, request *http.Request) (interface{}, error) {
|
||||
vb, err := GetVultureBackend(request)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user