88 "net"
99 "net/http"
1010 "strings"
11+ "time"
1112
1213 "github.com/gorilla/context"
1314 "github.com/gorilla/mux"
@@ -25,7 +26,8 @@ type RequestVars struct {
2526}
2627
2728type BatchVars struct {
28- Objects []* RequestVars `json:"objects"`
29+ Operation string `json:"operation"`
30+ Objects []* RequestVars `json:"objects"`
2931}
3032
3133// MetaObject is object metadata as seen by the object and metadata stores.
@@ -37,9 +39,15 @@ type MetaObject struct {
3739
3840// Representation is object medata as seen by clients of the lfs server.
3941type Representation struct {
40- Oid string `json:"oid"`
41- Size int64 `json:"size"`
42- Links map [string ]* link `json:"_links"`
42+ Oid string `json:"oid"`
43+ Size int64 `json:"size"`
44+ Actions map [string ]* link `json:"actions"`
45+ Error * ObjectError `json:"error,omitempty"`
46+ }
47+
48+ type ObjectError struct {
49+ Code int `json:"code"`
50+ Message string `json:"message"`
4351}
4452
4553// ObjectLink builds a URL linking to the object.
@@ -55,8 +63,9 @@ func (v *RequestVars) ObjectLink() string {
5563
5664// link provides a structure used to build a hypermedia representation of an HTTP link.
5765type link struct {
58- Href string `json:"href"`
59- Header map [string ]string `json:"header,omitempty"`
66+ Href string `json:"href"`
67+ Header map [string ]string `json:"header,omitempty"`
68+ ExpiresAt time.Time `json:"expires_at,omitempty"`
6069}
6170
6271// App links a Router, ContentStore, and MetaStore to provide the LFS server.
@@ -239,9 +248,9 @@ func (a *App) PutHandler(w http.ResponseWriter, r *http.Request) {
239248// for json encoding
240249func (a * App ) Represent (rv * RequestVars , meta * MetaObject , download , upload bool ) * Representation {
241250 rep := & Representation {
242- Oid : meta .Oid ,
243- Size : meta .Size ,
244- Links : make (map [string ]* link ),
251+ Oid : meta .Oid ,
252+ Size : meta .Size ,
253+ Actions : make (map [string ]* link ),
245254 }
246255
247256 header := make (map [string ]string )
@@ -250,11 +259,11 @@ func (a *App) Represent(rv *RequestVars, meta *MetaObject, download, upload bool
250259 header ["Authorization" ] = rv .Authorization
251260 }
252261 if download {
253- rep .Links ["download" ] = & link {Href : rv .ObjectLink (), Header : header }
262+ rep .Actions ["download" ] = & link {Href : rv .ObjectLink (), Header : header }
254263 }
255264
256265 if upload {
257- rep .Links ["upload" ] = & link {Href : rv .ObjectLink (), Header : header }
266+ rep .Actions ["upload" ] = & link {Href : rv .ObjectLink (), Header : header }
258267 }
259268 return rep
260269}
0 commit comments