2016-12-20 19:47:36 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "net/http"
|
|
|
|
|
|
|
|
// Route represents a path of the API
|
|
|
|
type Route struct {
|
|
|
|
Name string
|
|
|
|
Method string
|
|
|
|
Pattern string
|
|
|
|
HandlerFunc http.HandlerFunc
|
|
|
|
}
|
|
|
|
|
|
|
|
// Routes is an array of routes
|
|
|
|
type Routes []Route
|
|
|
|
|
|
|
|
var routes = Routes{
|
|
|
|
Route{
|
|
|
|
"Redirect to /buckets",
|
|
|
|
"GET",
|
|
|
|
"/",
|
|
|
|
indexPageHandler,
|
|
|
|
},
|
|
|
|
Route{
|
|
|
|
"Load Buckets Page",
|
|
|
|
"GET",
|
|
|
|
"/buckets",
|
|
|
|
bucketsPageHandler,
|
|
|
|
},
|
|
|
|
Route{
|
|
|
|
"Load Bucket Page",
|
|
|
|
"GET",
|
2016-12-21 00:32:40 +01:00
|
|
|
"/buckets/{bucketName}",
|
2016-12-20 19:47:36 +01:00
|
|
|
bucketPageHandler,
|
|
|
|
},
|
2016-12-21 00:32:40 +01:00
|
|
|
Route{
|
|
|
|
"Create Bucket",
|
|
|
|
"POST",
|
|
|
|
"/api/buckets",
|
|
|
|
createBucketHandler,
|
|
|
|
},
|
|
|
|
Route{
|
|
|
|
"Download Object",
|
|
|
|
"GET",
|
|
|
|
"/api/buckets/{bucketName}/objects/{objectName}",
|
|
|
|
getObjectHandler,
|
|
|
|
},
|
2016-12-21 01:45:07 +01:00
|
|
|
Route{
|
|
|
|
"Upload Object",
|
|
|
|
"POST",
|
|
|
|
"/api/buckets/{bucketName}/objects",
|
|
|
|
createObjectHandler,
|
|
|
|
},
|
2016-12-21 00:32:40 +01:00
|
|
|
Route{
|
|
|
|
"Delete Object",
|
|
|
|
"DELETE",
|
|
|
|
"/api/buckets/{bucketName}/objects/{objectName}",
|
|
|
|
deleteObjectHandler,
|
|
|
|
},
|
2016-12-20 19:47:36 +01:00
|
|
|
}
|