本文整理匯總了Golang中github.com/go-martini/martini.ClassicMartini.Delete方法的典型用法代碼示例。如果您正苦於以下問題:Golang ClassicMartini.Delete方法的具體用法?Golang ClassicMartini.Delete怎麽用?Golang ClassicMartini.Delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/go-martini/martini.ClassicMartini
的用法示例。
在下文中一共展示了ClassicMartini.Delete方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SetupApiEndpoints
/**
* attach all api endpoints
*/
func SetupApiEndpoints(m *martini.ClassicMartini) {
m.Get("/api/:project", GetProject)
m.Put("/api/:project", PutProject)
m.Delete("/api/:project", DeleteProject)
m.Get("/api/:project/translation/:key", GetTranslation)
m.Put("/api/:project/translation/:key/:locale", PutLocale)
m.Delete("/api/:project/translation/:key/:locale", DeleteLocale)
m.Get("/api/:project/file/:locale", GetLanguageFile)
m.Put("/api/:project/file/:locale", PutLanguageFile)
}
示例2: RegisterWebService
func RegisterWebService(server *martini.ClassicMartini) {
path := "/api/v1/keys"
server.Get(path, Get)
//server.Get(path+"/:email", Get)
server.Post(path, Post)
server.Delete(path, Delete)
server.Delete(path+"/:id", Delete)
}
示例3: setupUsersCtrl
func setupUsersCtrl(app *martini.ClassicMartini) {
app.Group("/users", func(r martini.Router) {
app.Get("", usersIndexAction)
app.Get("/add", usersAddAction)
app.Post("", sessions.RequireCsrfToken, usersCreateAction)
app.Get("/:id", usersEditAction)
app.Put("/:id", sessions.RequireCsrfToken, usersUpdateAction)
app.Delete("/:id", sessions.RequireCsrfToken, usersDeleteAction)
app.Get("/:id/delete", usersDeleteConfirmAction)
}, sessions.RequireLogin)
}
示例4: registerRoutes
func registerRoutes(server *martini.ClassicMartini) {
// Box
server.Post("/boxes", binding.Bind(request.CreateRequest{}), boxCreate)
server.Put("/boxes/:name", binding.Bind(request.DeployRequest{}), boxDeploy)
server.Get("/boxes", boxList)
server.Get("/boxes/:name", boxInspect)
server.Delete("/boxes/:name", boxDelete)
// Domain
server.Post("/boxes/:name/domain", binding.Bind(request.Domain{}), domainAdd)
server.Delete("/boxes/:name/domain/:domain", domainDelete)
}
示例5: RegisterRESTFunction
func RegisterRESTFunction(f RESTFunction, cm *martini.ClassicMartini) {
path := f.GetPath()
cm.Get(path, f.RGet)
cm.Get(path+"/:id", f.RGet)
cm.Post(path, f.RPost)
cm.Post(path+"/:id", f.RPost)
cm.Delete(path, f.RDelete)
cm.Delete(path+"/:id", f.RDelete)
}
示例6: RegisterWebService
// RegisterWebService adds martini routes to the relevant webservice methods
// based on the path returned by GetPath. Each method is registered once for
// the collection and once for each id in the collection.
func RegisterWebService(webService WebService,
classicMartini *martini.ClassicMartini) {
path := webService.GetPath()
classicMartini.Get(path, webService.WebGet)
classicMartini.Get(path+"/:id", webService.WebGet)
classicMartini.Post(path, webService.WebPost)
classicMartini.Post(path+"/:id", webService.WebPost)
classicMartini.Delete(path, webService.WebDelete)
classicMartini.Delete(path+"/:id", webService.WebDelete)
}
示例7: addLatestNewsRoutes
func addLatestNewsRoutes(m *martini.ClassicMartini) {
m.Get("/latest_news", ShowLatestNewsCollection)
m.Get("/latest_news/:id", EditLatestNews)
m.Post("/latest_news", CreateLatestNews)
m.Post("/latest_news/new", CreateLatestNews)
m.Put("/latest_news/:id", UpdateLatestNews)
m.Post("/latest_news/:id", UpdateLatestNews)
m.Delete("/latest_news/:id", DeleteLatestNews)
m.Get("/latest_news/del/:id", DeleteLatestNews)
}
示例8: addComponentRoutes
func addComponentRoutes(m *martini.ClassicMartini) {
m.Get("/component", ShowComponents)
m.Get("/component/:id", EditComponent)
m.Post("/component", CreateComponent)
m.Post("/component/new", CreateComponent)
m.Put("/component/:id", UpdateComponent)
m.Post("/component/:id", UpdateComponent)
m.Delete("/component/:id", DeleteComponent)
m.Get("/component/del/:id", DeleteComponent)
}
示例9: addInvertebrateRoutes
func addInvertebrateRoutes(m *martini.ClassicMartini) {
m.Get("/invertebrate", ShowInvertebrates)
m.Get("/invertebrate/:id", EditInvertebrate)
m.Post("/invertebrate", CreateInvertebrate)
m.Post("/invertebrate/new", CreateInvertebrate)
m.Put("/invertebrate/:id", UpdateInvertebrate)
m.Post("/invertebrate/:id", UpdateInvertebrate)
m.Delete("/invertebrate/:id", DeleteInvertebrate)
m.Get("/invertebrate/del/:id", DeleteInvertebrate)
}
示例10: addCoralRoutes
func addCoralRoutes(m *martini.ClassicMartini) {
m.Get("/coral", ShowCorals)
m.Get("/coral/:id", EditCoral)
m.Post("/coral", CreateCoral)
m.Post("/coral/new", CreateCoral)
m.Put("/coral/:id", UpdateCoral)
m.Post("/coral/:id", UpdateCoral)
m.Delete("/coral/:id", DeleteCoral)
m.Get("/coral/del/:id", DeleteCoral)
}
示例11: addPlantRoutes
func addPlantRoutes(m *martini.ClassicMartini) {
m.Get("/plant", ShowPlants)
m.Get("/plant/:id", EditPlant)
m.Post("/plant", CreatePlant)
m.Post("/plant/new", CreatePlant)
m.Put("/plant/:id", UpdatePlant)
m.Post("/plant/:id", UpdatePlant)
m.Delete("/plant/:id", DeletePlant)
m.Get("/plant/del/:id", DeletePlant)
}
示例12: addInhabitantRoutes
func addInhabitantRoutes(m *martini.ClassicMartini) {
m.Get("/inhabitant", ShowInhabitants)
m.Get("/inhabitant/:id", EditInhabitant)
m.Post("/inhabitant", CreateInhabitant)
m.Post("/inhabitant/new", CreateInhabitant)
m.Put("/inhabitant/:id", UpdateInhabitant)
m.Post("/inhabitant/:id", UpdateInhabitant)
m.Delete("/inhabitant/:id", DeleteInhabitant)
m.Get("/inhabitant/del/:id", DeleteInhabitant)
}
示例13: setupConsumersCtrl
func setupConsumersCtrl(app *martini.ClassicMartini) {
app.Group("/consumers", func(r martini.Router) {
app.Get("", consumersIndexAction)
app.Get("/add", consumersAddAction)
app.Post("", sessions.RequireCsrfToken, consumersCreateAction)
app.Get("/:id", consumersEditAction)
app.Put("/:id", sessions.RequireCsrfToken, consumersUpdateAction)
app.Delete("/:id", sessions.RequireCsrfToken, consumersDeleteAction)
app.Get("/:id/delete", consumersDeleteConfirmAction)
app.Get("/:id/urls", consumersUrlsAction)
}, sessions.RequireLogin)
// public
app.Get("/info/:consumer/:token", consumerInfoAction)
}
示例14: SetupAuth
func SetupAuth(martini *martini.ClassicMartini) {
os.Mkdir(backendfile, 0755)
backend_, err := httpauth.NewLeveldbAuthBackend(backendfile)
if err != nil {
log.Fatal(err.Error())
}
backend = backend_
roles = make(map[string]httpauth.Role)
roles["user"] = 30
roles["admin"] = 80
aaa, err = httpauth.NewAuthorizer(backend, []byte("cookie-encryption-key"), "user", roles)
if err != nil {
log.Fatal(err.Error())
}
users, err := backend.Users()
if err != nil || len(users) == 0 {
// create a default user
hash, err := bcrypt.GenerateFromPassword([]byte("toor"), bcrypt.DefaultCost)
//hash, err := bcrypt.GenerateFromPassword([]byte("l4ngu4g3"), bcrypt.DefaultCost)
if err != nil {
panic(err)
}
defaultUser := httpauth.UserData{Username: "root", Email: "", Hash: hash, Role: "admin"}
//defaultUser := httpauth.UserData{Username: "commscope", Email: "", Hash: hash, Role: "admin"}
err = backend.SaveUser(defaultUser)
if err != nil {
panic(err)
}
}
martini.Post("/auth/login", doLogin)
martini.Get("/auth/logout", doLogout)
martini.Get("/auth/token", doGetToken)
martini.Post("/auth/user", AssertRole("admin"), doAddUser)
martini.Get("/auth/currentuser", doGetCurrentUser)
martini.Get("/auth/user", AssertRole("admin"), doGetUsers)
martini.Get("/auth/user/:username", AssertRole("admin"), doGetUser)
martini.Put("/auth/user/:username", AssertRole("admin"), doUpdateUser)
martini.Delete("/auth/user/:username", AssertRole("admin"), doDeleteUser)
martini.Post("/auth/user/:username/allow", AssertRole("admin"), doAllow)
martini.Post("/auth/user/:username/forbid", AssertRole("admin"), doForbid)
}
示例15: api
func api(mart *martini.ClassicMartini) {
var engine = backend.GetEngine()
mart.Post(API+"/datasets/?", binding.Bind(DatasetForm{}), func(form DatasetForm, r render.Render) {
var err error
var file *backend.File
var tag *backend.Tag
var dataset *backend.Dataset
if form.FileId > 0 {
file = &backend.File{Id: form.FileId}
if has, _ := engine.Get(file); !has {
r.JSON(http.StatusOK, map[string]interface{}{"err": "file not exists."})
return
}
} else {
if file, err = backend.UploadFile(form.File); err != nil {
r.JSON(http.StatusInternalServerError, map[string]interface{}{"err": err.Error()})
return
}
}
if tag, err = backend.SaveTag(form.Tag); err != nil {
r.JSON(http.StatusInternalServerError, map[string]interface{}{"err": err.Error()})
return
}
if dataset, err = backend.SaveDataset(file, tag, form.DataType, form.Description); err != nil {
r.JSON(http.StatusInternalServerError, map[string]interface{}{"err": err.Error()})
return
}
r.JSON(http.StatusOK, map[string]*backend.Dataset{"dataset": dataset})
})
mart.Post(API+"/datasets/(?P<dataset_id>\\d+)/?", func(req *http.Request, params martini.Params, r render.Render) {
datasetId, _ := strconv.Atoi(params["dataset_id"])
var dataset = new(backend.Dataset)
if has, err := engine.Id(datasetId).Get(dataset); err != nil {
r.JSON(http.StatusInternalServerError, map[string]string{"err": err.Error()})
} else if has {
dataset.FillObject()
dataset.Description = req.Form.Get("description")
if _, err := engine.Id(datasetId).Update(dataset); err != nil {
r.JSON(http.StatusInternalServerError, map[string]string{"err": err.Error()})
return
}
r.JSON(http.StatusOK, map[string]*backend.Dataset{"dataset": dataset})
} else {
r.JSON(http.StatusNotFound, map[string]string{"err": "Dataset not exists."})
}
})
mart.Get(API+"/datasets/(?P<dataset_id>\\d+)/?", func(params martini.Params, r render.Render) {
datasetId, _ := strconv.Atoi(params["dataset_id"])
var dataset = new(backend.Dataset)
if has, err := engine.Id(datasetId).Get(dataset); err != nil {
r.JSON(http.StatusInternalServerError, map[string]string{"err": err.Error()})
} else if has {
dataset.FillObject()
r.JSON(http.StatusOK, map[string]*backend.Dataset{"dataset": dataset})
} else {
r.JSON(http.StatusNotFound, map[string]string{"err": "Dataset not exists."})
}
})
mart.Delete(API+"/datasets/(?P<dataset_id>\\d+)/?", func(params martini.Params, r render.Render) {
datasetId, _ := strconv.Atoi(params["dataset_id"])
var dataset = new(backend.Dataset)
if has, err := engine.Id(datasetId).Get(dataset); err != nil {
r.JSON(http.StatusInternalServerError, map[string]string{"err": err.Error()})
} else if has {
if _, err := engine.Id(datasetId).Delete(dataset); err != nil {
r.JSON(http.StatusInternalServerError, map[string]string{"err": err.Error()})
} else {
var sql string
if dataset.DataType == backend.TRAIN {
sql = "update `tag` set `train_count` = `train_count` - 1 where `id` = ?"
} else if dataset.DataType == backend.VAL {
sql = "update `tag` set `test_count` = `test_count` - 1 where `id` = ?"
}
engine.Exec(sql, dataset.TagId)
r.JSON(http.StatusOK, map[string]string{})
}
} else {
r.JSON(http.StatusNotFound, map[string]string{"err": "Dataset not exists."})
}
})
mart.Get(API+"/datasets/?", func(req *http.Request, r render.Render) {
var qs = req.URL.Query()
var err error
var max, limit int
if max, err = strconv.Atoi(qs.Get("max")); err != nil {
max = -1
}
if limit, err = strconv.Atoi(qs.Get("limit")); err != nil {
limit = 10
}
//.........這裏部分代碼省略.........