本文整理匯總了Golang中github.com/flynn/flynn/Godeps/_workspace/src/github.com/julienschmidt/httprouter.Router.DELETE方法的典型用法代碼示例。如果您正苦於以下問題:Golang Router.DELETE方法的具體用法?Golang Router.DELETE怎麽用?Golang Router.DELETE使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/flynn/flynn/Godeps/_workspace/src/github.com/julienschmidt/httprouter.Router
的用法示例。
在下文中一共展示了Router.DELETE方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RegisterRoutes
func (api *HTTPAPI) RegisterRoutes(r *httprouter.Router) {
r.POST("/storage/providers", api.CreateProvider)
r.POST("/storage/providers/:provider_id/volumes", api.Create)
r.GET("/storage/volumes", api.List)
r.GET("/storage/volumes/:volume_id", api.Inspect)
r.DELETE("/storage/volumes/:volume_id", api.Destroy)
r.PUT("/storage/volumes/:volume_id/snapshot", api.Snapshot)
// takes host and volID parameters, triggers a send on the remote host and give it a list of snaps already here, and pipes it into recv
r.POST("/storage/volumes/:volume_id/pull_snapshot", api.Pull)
// responds with a snapshot stream binary. only works on snapshots, takes 'haves' parameters, usually called by a node that's servicing a 'pull_snapshot' request
r.GET("/storage/volumes/:volume_id/send", api.Send)
}
示例2: RegisterRoutes
func (h *jobAPI) RegisterRoutes(r *httprouter.Router) error {
r.GET("/host/jobs", h.ListJobs)
r.GET("/host/jobs/:id", h.GetJob)
r.PUT("/host/jobs/:id", h.AddJob)
r.DELETE("/host/jobs/:id", h.StopJob)
r.PUT("/host/jobs/:id/signal/:signal", h.SignalJob)
r.POST("/host/pull-images", h.PullImages)
r.POST("/host/discoverd", h.ConfigureDiscoverd)
r.POST("/host/network", h.ConfigureNetworking)
r.GET("/host/status", h.GetStatus)
return nil
}
示例3: RegisterRoutes
func (h *jobAPI) RegisterRoutes(r *httprouter.Router) error {
r.GET("/host/jobs", h.ListJobs)
r.GET("/host/jobs/:id", h.GetJob)
r.PUT("/host/jobs/:id", h.AddJob)
r.DELETE("/host/jobs/:id", h.StopJob)
r.PUT("/host/jobs/:id/signal/:signal", h.SignalJob)
r.POST("/host/pull/images", h.PullImages)
r.POST("/host/pull/binaries", h.PullBinariesAndConfig)
r.POST("/host/discoverd", h.ConfigureDiscoverd)
r.POST("/host/network", h.ConfigureNetworking)
r.GET("/host/status", h.GetStatus)
r.POST("/host/resource-check", h.ResourceCheck)
r.POST("/host/update", h.Update)
return nil
}
示例4: crud
func crud(r *httprouter.Router, resource string, example interface{}, repo Repository) {
resourceType := reflect.TypeOf(example)
prefix := "/" + resource
r.POST(prefix, httphelper.WrapHandler(func(ctx context.Context, rw http.ResponseWriter, req *http.Request) {
thing := reflect.New(resourceType).Interface()
if err := httphelper.DecodeJSON(req, thing); err != nil {
respondWithError(rw, err)
return
}
if err := schema.Validate(thing); err != nil {
respondWithError(rw, err)
return
}
if err := repo.Add(thing); err != nil {
respondWithError(rw, err)
return
}
httphelper.JSON(rw, 200, thing)
}))
lookup := func(ctx context.Context) (interface{}, error) {
params, _ := ctxhelper.ParamsFromContext(ctx)
return repo.Get(params.ByName(resource + "_id"))
}
singletonPath := prefix + "/:" + resource + "_id"
r.GET(singletonPath, httphelper.WrapHandler(func(ctx context.Context, rw http.ResponseWriter, _ *http.Request) {
thing, err := lookup(ctx)
if err != nil {
respondWithError(rw, err)
return
}
httphelper.JSON(rw, 200, thing)
}))
r.GET(prefix, httphelper.WrapHandler(func(ctx context.Context, rw http.ResponseWriter, _ *http.Request) {
list, err := repo.List()
if err != nil {
respondWithError(rw, err)
return
}
httphelper.JSON(rw, 200, list)
}))
if remover, ok := repo.(Remover); ok {
r.DELETE(singletonPath, httphelper.WrapHandler(func(ctx context.Context, rw http.ResponseWriter, _ *http.Request) {
_, err := lookup(ctx)
if err != nil {
respondWithError(rw, err)
return
}
params, _ := ctxhelper.ParamsFromContext(ctx)
if err = remover.Remove(params.ByName(resource + "_id")); err != nil {
respondWithError(rw, err)
return
}
rw.WriteHeader(200)
}))
}
}