本文整理汇总了Golang中github.com/ant0ine/go-json-rest/rest.Delete函数的典型用法代码示例。如果您正苦于以下问题:Golang Delete函数的具体用法?Golang Delete怎么用?Golang Delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Delete函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Route
func Route() (rest.App, error) {
return rest.MakeRouter(
// 新增某个服务
rest.Post("/apps", restGuarder(handler.CreateAppsHandler)),
// 获取所有服务的基本信息
rest.Get("/apps", restGuarder(handler.GetInfoAppsHandler)),
// TODO 获取某一个服务的详细信息
rest.Get("/apps/*appId", restGuarder(handler.GetSingleAppsHandler)),
// 删除某一个服务的所有实例
rest.Delete("/apps/*appId", restGuarder(handler.DeleteAppsHandler)),
// 新增或者更新一批服务
rest.Post("/apps/updater", restGuarder(handler.CreateOrUpdateAppsHandler)),
// 回滚一批服务
rest.Post("/apps/rollback", restGuarder(handler.RollbackAppsHandler)),
// 新增一批组信息
rest.Post("/groups", restGuarder(handler.DeployGroupsHandler)),
// 给新增容器获取一个IP
rest.Get("/ipholder/*cId", restGuarder(handler.CreateIpForContainer)),
// 给删除容器释放所占用的IP
rest.Delete("/ipholder/*cId", restGuarder(handler.DeleteIpForContainer)),
// 填写某个容器信息
rest.Post("/containers", restGuarder(handler.CreateContainerInfo)),
// 更新容器状态
rest.Post("/containers/:cId/:cState", restGuarder(handler.UpdateStateContainerInfo)),
// 软删除容器
rest.Delete("/containers/soft/*cId", restGuarder(handler.MaskContainerInfo)),
)
}
开发者ID:zufangzi,项目名称:chaos,代码行数:31,代码来源:route.go
示例2: initRoutes
func initRoutes(restApi *rest.Api) {
authController := &AuthController{}
appController := &ApplicationController{}
typesController := &TypesController{}
router, err := rest.MakeRouter(
rest.Put(authController.Path(), authController.RegisterUserHandler),
rest.Post(authController.Path(), authController.LoginUserHandler),
rest.Put("/:appId"+authController.Path(), authController.AppRegisterUserHandler),
rest.Post("/:appId"+authController.Path(), authController.AppLoginUserHandler),
rest.Post(appController.Path(), appController.CreateApplicationHandler),
rest.Get(appController.Path(), appController.GetApplicationsHandler),
rest.Get(appController.Path()+"/:appId", appController.GetApplicationHandler),
rest.Delete(appController.Path()+"/:appId", appController.DeleteApplicationHandler),
rest.Put(appController.Path()+"/:appId", appController.UpdateApplicationHandler),
rest.Post("/:appId"+typesController.Path(), typesController.CreateTypeHandler),
rest.Delete("/:appId"+typesController.Path()+"/:typeName", typesController.DeleteType),
rest.Post("/:appId"+typesController.Path()+"/:typeName", typesController.InsertInTypeHandler),
rest.Get("/:appId"+typesController.Path()+"/:typeName", typesController.GetTypeDataHandler),
rest.Get("/:appId"+typesController.Path()+"/:typeName/:itemId", typesController.GetTypeItemById),
rest.Put("/:appId"+typesController.Path()+"/:typeName/:itemId", typesController.UpdateTypeItemById),
rest.Delete("/:appId"+typesController.Path()+"/:typeName/:itemId", typesController.DeleteTypeItemById),
)
if err != nil {
log.Fatal(err)
}
restApi.SetApp(router)
}
开发者ID:gitter-badger,项目名称:neutrino-core,代码行数:32,代码来源:api.go
示例3: main
func main() {
var err error
api := rest.NewApi()
// Enable basic middlewares.
api.Use(rest.DefaultDevStack...)
// Enable CORS middleware.
api.Use(&rest.CorsMiddleware{
RejectNonCorsRequests: false,
OriginValidator: func(origin string, request *rest.Request) bool {
return true
},
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE"},
AllowedHeaders: []string{
"Accept", "Content-Type", "X-Custom-Header", "Origin"},
AccessControlAllowCredentials: true,
AccessControlMaxAge: 3600,
})
// Enable token validation middleware.
api.Use(&mw.AuthMW{})
router, err := rest.MakeRouter(
// cards.
rest.Get("/cards", GetUserCards),
rest.Get("/cards/:cid", GetCard),
rest.Post("/cards", CreateCard),
rest.Put("/cards/:cid", UpdateCard),
rest.Delete("/cards/:cid", DeleteCard),
rest.Get("/challenge", GetChallenge),
rest.Post("/results", SaveResult),
// user endpoints.
rest.Get("/users/:uid", GetUser),
rest.Put("/users/:uid", UpdateUser),
rest.Delete("/users/:uid", DeleteUser),
// token
rest.Post("/token", GetToken),
// ping
rest.Get("/ping", Ping),
)
if err != nil {
log.Fatal(err)
}
api.SetApp(router)
log.Fatal(http.ListenAndServe(":8080", api.MakeHandler()))
}
开发者ID:hairqles,项目名称:scholar,代码行数:52,代码来源:main.go
示例4: main
func main() {
i := Impl{}
i.InitDB()
i.InitSchema()
api := rest.NewApi()
api.Use(rest.DefaultDevStack...)
api.Use(&rest.CorsMiddleware{
RejectNonCorsRequests: false,
OriginValidator: func(origin string, request *rest.Request) bool {
return true
},
AllowedMethods: []string{"GET", "POST", "PUT"},
AllowedHeaders: []string{
"Accept", "Content-Type", "X-Custom-Header", "Origin"},
AccessControlAllowCredentials: true,
AccessControlMaxAge: 3600,
})
router, err := rest.MakeRouter(
rest.Get("/services", i.GetAllServices),
rest.Post("/services", i.PostService),
rest.Get("/services/:id", i.GetService),
rest.Put("/services/:id", i.PutService),
rest.Delete("/services/:id", i.DeleteService),
)
if err != nil {
log.Fatal(err)
}
api.SetApp(router)
log.Fatal(http.ListenAndServe(":8080", api.MakeHandler()))
}
开发者ID:mrcsparker,项目名称:translator-training,代码行数:31,代码来源:main.go
示例5: serveREST
func (r *Controller) serveREST(conf *goconf.ConfigFile) {
c, err := parseRESTConfig(conf)
if err != nil {
r.log.Err(fmt.Sprintf("Controller: parsing REST configurations: %v", err))
return
}
api := rest.NewApi()
router, err := rest.MakeRouter(
rest.Get("/api/v1/switch", r.listSwitch),
rest.Post("/api/v1/switch", r.addSwitch),
rest.Delete("/api/v1/switch/:id", r.removeSwitch),
rest.Options("/api/v1/switch/:id", r.allowOrigin),
rest.Get("/api/v1/port/:switchID", r.listPort),
rest.Get("/api/v1/network", r.listNetwork),
rest.Post("/api/v1/network", r.addNetwork),
rest.Delete("/api/v1/network/:id", r.removeNetwork),
rest.Options("/api/v1/network/:id", r.allowOrigin),
rest.Get("/api/v1/ip/:networkID", r.listIP),
rest.Get("/api/v1/host", r.listHost),
rest.Post("/api/v1/host", r.addHost),
rest.Delete("/api/v1/host/:id", r.removeHost),
rest.Options("/api/v1/host/:id", r.allowOrigin),
rest.Get("/api/v1/vip", r.listVIP),
rest.Post("/api/v1/vip", r.addVIP),
rest.Delete("/api/v1/vip/:id", r.removeVIP),
rest.Options("/api/v1/vip/:id", r.allowOrigin),
rest.Put("/api/v1/vip/:id", r.toggleVIP),
)
if err != nil {
r.log.Err(fmt.Sprintf("Controller: making a REST router: %v", err))
return
}
api.SetApp(router)
addr := fmt.Sprintf(":%v", c.port)
if c.tls.enable {
err = http.ListenAndServeTLS(addr, c.tls.certFile, c.tls.keyFile, api.MakeHandler())
} else {
err = http.ListenAndServe(addr, api.MakeHandler())
}
if err != nil {
r.log.Err(fmt.Sprintf("Controller: listening on HTTP: %v", err))
return
}
}
开发者ID:yebinMoon,项目名称:cherry,代码行数:47,代码来源:controller.go
示例6: getRouter
func getRouter() (rest.App, error) {
mcPlugins := routes.McPlugins{}
router, err := rest.MakeRouter(
rest.Get("/plugins", mcPlugins.GetAllPlugins),
rest.Post("/plugins", mcPlugins.PostPlugin),
rest.Get("/plugins/:id", mcPlugins.GetPlugin),
rest.Put("/plugins/:id", mcPlugins.PutPlugin),
rest.Delete("/plugins/:id", mcPlugins.DeletePlugin),
)
return router, err
}
开发者ID:AndyEverLie,项目名称:mc_api,代码行数:12,代码来源:main.go
示例7: RunServer
func (fe *Frontend) RunServer(blocking bool) http.Handler {
api := rest.NewApi()
api.Use(&rest.AuthBasicMiddleware{
Realm: "test zone",
Authenticator: func(userId string, password string) bool {
if userId == fe.cfg.Network.Username &&
password == fe.cfg.Network.Password {
return true
}
return false
},
})
api.Use(rest.DefaultDevStack...)
router, err := rest.MakeRouter(
rest.Get("/subnets", fe.GetAllSubnets),
rest.Get("/subnets/#id", fe.GetSubnet),
rest.Post("/subnets", fe.CreateSubnet),
rest.Put("/subnets/#id", fe.UpdateSubnet),
rest.Delete("/subnets/#id", fe.DeleteSubnet),
rest.Post("/subnets/#id/bind", fe.BindSubnet),
rest.Delete("/subnets/#id/bind/#mac", fe.UnbindSubnet),
rest.Put("/subnets/#id/next_server/#ip", fe.NextServer),
)
if err != nil {
log.Fatal(err)
}
api.SetApp(router)
connStr := fmt.Sprintf(":%d", fe.cfg.Network.Port)
log.Println("Web Interface Using", connStr)
if blocking {
if fe.cert_pem == "" || fe.key_pem == "" {
log.Fatal(http.ListenAndServe(connStr, api.MakeHandler()))
} else {
log.Fatal(http.ListenAndServeTLS(connStr, fe.cert_pem, fe.key_pem, api.MakeHandler()))
}
}
return api.MakeHandler()
}
开发者ID:galthaus,项目名称:ocb-dhcp,代码行数:39,代码来源:api.go
示例8: main
func main() {
// serve ng-admin angular app
fs := http.FileServer(http.Dir("static"))
http.Handle("/admin/", http.StripPrefix("/admin/", fs))
db, err := sql.Open("sqlite3", "./blog.db")
defer db.Close()
if err != nil {
panic(err)
}
api := rest.NewApi()
api.Use(rest.DefaultProdStack...)
api.Use(&rest.CorsMiddleware{
RejectNonCorsRequests: false,
OriginValidator: func(origin string, request *rest.Request) bool {
return true
},
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE"},
AllowedHeaders: []string{
"Accept", "Content-Type", "X-Total-Count", "Origin"},
AccessControlAllowCredentials: true,
AccessControlMaxAge: 3600,
})
// initialize Entity REST API
entityManager := eram.NewEntityDbManager(db)
entityRestApi := era.NewEntityRestAPI(entityManager)
router, err := rest.MakeRouter(
rest.Get("/api/:entity", entityRestApi.GetAllEntities),
rest.Post("/api/:entity", entityRestApi.PostEntity),
rest.Get("/api/:entity/:id", entityRestApi.GetEntity),
rest.Put("/api/:entity/:id", entityRestApi.PutEntity),
rest.Delete("/api/:entity/:id", entityRestApi.DeleteEntity),
)
if err != nil {
log.Fatal(err)
}
api.SetApp(router)
http.Handle("/api/", api.MakeHandler())
log.Fatal(http.ListenAndServe(":8080", nil))
}
开发者ID:Onefootball,项目名称:entity-rest-api,代码行数:50,代码来源:main.go
示例9: NewApi
func NewApi() *ApiHander {
handler := ApiHandler{
Api: rest.NewApi(),
}
handler.Api.Use(rest.DefaultDevStack...)
router, err := rest.MakeRouter(
rest.Post("/jobs", handler.CreateJob),
rest.Get("/jobs", handler.GetJobs),
rest.Get("/jobs/:id", handler.GetJob),
rest.Put("/jobs/:id", handler.UpdateJob),
rest.Delete("/jobs/:id", handler.DeleteJob),
rest.Post("/procs", handler.StartProc),
rest.Get("/procs/:id", handler.GetProc),
rest.Delete("/procs/:id", handler.StopProc),
rest.Get("/jobs/:id/procs", handler.GetProcsByJob),
rest.Get("/jobs/:id/log", handler.GetProcLogByJob),
)
if err != nil {
log.Fatal(err)
}
handler.Api.SetApp(router)
return &handler
}
开发者ID:siroken3,项目名称:cronng,代码行数:23,代码来源:api.go
示例10: main
func main() {
users := Users{
Store: map[string]*User{},
}
books := Books{
Store: map[string]*Book{},
}
api := rest.NewApi()
api.Use(rest.DefaultDevStack...)
router, err := rest.MakeRouter(
// users router
rest.Get("/users", users.GetAllUsers),
rest.Post("/users", users.PostUser),
rest.Get("/users/:id", users.GetUser),
rest.Put("/users/:id", users.PutUser),
rest.Delete("/users/:id", users.DeleteUser),
// user and book router
rest.Get("/users/:id/books", users.GetUserAllBooks),
// books router
rest.Get("/books", books.GetAllBooks),
rest.Post("/books", books.PostBook),
rest.Get("/books/:id", books.GetBook),
rest.Put("/books/:id", books.PutBook),
rest.Delete("/books/:id", books.DeleteBook),
)
if err != nil {
log.Fatal(err)
}
api.SetApp(router)
log.Fatal(http.ListenAndServe(":8080", api.MakeHandler()))
}
开发者ID:cyy0523xc,项目名称:code,代码行数:36,代码来源:restful-api-user-book.go
示例11: main
func main() {
api := rest.NewApi()
api.Use(rest.DefaultDevStack...)
router, err := rest.MakeRouter(
rest.Get("/countries", GetAllCountries),
rest.Post("/countries", PostCountry),
rest.Get("/countries/:code", GetCountry),
rest.Delete("/countries/:code", DeleteCountry),
)
if err != nil {
log.Fatal(err)
}
api.SetApp(router)
log.Fatal(http.ListenAndServe(":8080", api.MakeHandler()))
}
开发者ID:jemkzheng,项目名称:go-json-rest-examples,代码行数:15,代码来源:main.go
示例12: main
func main() {
init_db()
api := rest.NewApi()
api.Use(rest.DefaultDevStack...)
router, err := rest.MakeRouter(
rest.Get("/os", GetAllOS),
rest.Post("/os", PostOS),
rest.Get("/os/:Distribution", GetOS),
rest.Delete("/os/:Distribution", DeleteOS),
)
if err != nil {
log.Fatal(err)
}
api.SetApp(router)
log.Fatal(http.ListenAndServe(":8080", api.MakeHandler()))
}
开发者ID:liangchenye,项目名称:go-hack,代码行数:17,代码来源:main.go
示例13: main
func main() {
fmt.Println("****** Test for a product ******")
api := rest.NewApi()
api.Use(rest.DefaultDevStack...)
router, err := rest.MakeRouter(
rest.Get("/products", GetAllProducts),
rest.Post("/products", PostProduct),
rest.Get("/products/:id", GetProduct),
rest.Delete("/products/:id", DeleteProduct),
)
if err != nil {
log.Fatal(err)
}
api.SetApp(router)
log.Fatal(http.ListenAndServe(":8080", api.MakeHandler()))
log.Println("Listening on port 8080 -> go to http://localhost:8080")
}
开发者ID:ritoon,项目名称:golang-router-implementation-api,代码行数:17,代码来源:main.go
示例14: main
func main() {
// Static Files
fs := http.FileServer(http.Dir("app/dist"))
http.Handle("/", fs)
log.Println("Listening...")
go http.ListenAndServe(":8080", nil)
// Api
api := rest.NewApi()
api.Use(rest.DefaultDevStack...)
api.Use(&rest.CorsMiddleware{
RejectNonCorsRequests: false,
OriginValidator: func(origin string, request *rest.Request) bool {
return true // origin == "http://127.0.0.1"
},
AllowedMethods: []string{"GET", "POST", "PUT", "OPTIONS", "DELETE"},
AllowedHeaders: []string{
"Accept", "Content-Type", "Authorization", "Origin"},
AccessControlAllowCredentials: true,
AccessControlMaxAge: 3600,
})
api.Use(AuthMiddleware())
router, err := rest.MakeRouter(
rest.Post("/auth/login", restapi.Login),
rest.Post("/auth/register", restapi.Register),
rest.Post("/api/importurl", restapi.ImportUrl),
rest.Get("/api/documents", restapi.GetAllDocuments),
rest.Post("/api/documents", restapi.PostDocument),
rest.Get("/api/documents/:id", restapi.GetDocument),
rest.Put("/api/documents/:id", restapi.PutDocument),
rest.Delete("/api/documents/:id", restapi.DeleteDocument),
)
if err != nil {
log.Fatal(err)
}
api.SetApp(router)
log.Printf("Port %s\n", conf.Port)
log.Fatal(http.ListenAndServe(":"+conf.Port, api.MakeHandler()))
}
开发者ID:ds0nt,项目名称:markdown,代码行数:45,代码来源:api.go
示例15: main
func main() {
email := rest_email.Email{}
api := rest.NewApi()
api.Use(rest.DefaultDevStack...)
router, err := rest.MakeRouter(
rest.Get("/", email.GetServiceList),
rest.Get("/email", email.GetEmailListAndContent),
rest.Post("/email", email.SendEmailContent),
rest.Delete("/email", email.DeleteEmail),
)
if err != nil {
log.Fatal(err)
}
api.SetApp(router)
log.Printf("email api server start...")
log.Fatal(http.ListenAndServe(":8080", api.MakeHandler()))
}
开发者ID:yuanlv,项目名称:learning-in-go,代码行数:18,代码来源:main.go
示例16: main
func main() {
api := rest.NewApi()
api.Use(rest.DefaultDevStack...)
router, err := rest.MakeRouter(
rest.Post("/api/v1/images", HandleImageCreate),
rest.Get("/api/v1/images", HandleImageList),
rest.Post("/api/v1/instances", HandleInstanceCreate),
rest.Post("/api/v1/instances/:instanceid", HandleInstanceStart),
rest.Put("/api/v1/instances/:instanceid", HandleInstanceStop),
rest.Get("/api/v1/instances", HandleInstanceList),
rest.Get("/api/v1/instances/:instanceid", HandleInstanceInfo),
rest.Delete("/api/v1/instances/:instanceid", HandleInstanceDestroy),
)
if err != nil {
log.Fatal(err)
}
api.SetApp(router)
log.Fatal(http.ListenAndServe(listen, api.MakeHandler()))
}
开发者ID:gitter-badger,项目名称:pangolin,代码行数:19,代码来源:pangolin-api.go
示例17: NewRouter
// NewRouter return the configured routes for this API
func NewRouter(jwtmiddleware *jwt.JWTMiddleware, session *r.Session) rest.App {
trips := models.Trips{
Conn: session,
}
router, err := rest.MakeRouter(
rest.Post("/login", jwtmiddleware.LoginHandler),
rest.Get("/refresh_token", jwtmiddleware.RefreshHandler),
rest.Get("/trips", trips.GetAllTrips),
rest.Get("/trips/:id", trips.GetTrip),
rest.Post("/trips", trips.PostTrip),
rest.Patch("/trips/:id/updatePlaces", trips.UpdateTripPlaces),
rest.Delete("/trips/:id/deletePlace/:place", trips.DeleteTripPlaces),
)
if err != nil {
log.Fatal(err)
}
return router
}
开发者ID:yetis-br,项目名称:travelPlanning,代码行数:22,代码来源:routes.go
示例18: main
func main() {
api := rest.NewApi()
api.Use(rest.DefaultDevStack...)
router, err := rest.MakeRouter(
// TODO http://docs.aws.amazon.com/AWSEC2/latest/APIReference/OperationList-query.html
rest.Post("/api/v1/images", ImageCreate),
rest.Get("/api/v1/images", ImageList),
rest.Post("/api/v1/instances", InstanceCreate),
rest.Post("/api/v1/instances/:instanceid", InstanceStart),
rest.Put("/api/v1/instances/:instanceid", InstanceStop),
rest.Get("/api/v1/instances", InstanceList),
rest.Delete("/api/v1/instances/:instanceid", InstanceDestroy),
)
if err != nil {
log.Fatal(err)
}
api.SetApp(router)
log.Fatal(http.ListenAndServe(listen, api.MakeHandler()))
}
开发者ID:zchee,项目名称:pangolin,代码行数:22,代码来源:pangolin-api.go
示例19: init
func init() {
db, err := sql.Open("sqlite3", ":memory:")
if err != nil {
log.Fatal("An error '%s' was not expected when opening a stub database connection", err)
} else {
dat, err := ioutil.ReadFile("./../test.sql")
if err != nil {
log.Fatal("An error '%s' was not expected when opening sql file", err)
} else {
db.Exec(string(dat))
}
}
api := rest.NewApi()
api.Use(rest.DefaultDevStack...)
entityManager := eram.NewEntityDbManager(db)
entityRestApi := NewEntityRestAPI(entityManager)
router, err := rest.MakeRouter(
rest.Get("/api/:entity", entityRestApi.GetAllEntities),
rest.Post("/api/:entity", entityRestApi.PostEntity),
rest.Get("/api/:entity/:id", entityRestApi.GetEntity),
rest.Put("/api/:entity/:id", entityRestApi.PutEntity),
rest.Delete("/api/:entity/:id", entityRestApi.DeleteEntity),
)
if err != nil {
log.Fatal("An error '%s' was not expected when creating the router", err)
}
api.SetApp(router)
handler = api.MakeHandler()
server = httptest.NewServer(handler)
}
开发者ID:Onefootball,项目名称:entity-rest-api,代码行数:39,代码来源:entity_api_test.go
示例20: main
func main() {
// db, err := gorm.Open("postgres", "user=gorm dbname=gorm sslmode=disable")
// db, err := gorm.Open("foundation", "dbname=gorm") // FoundationDB.
// db, err := gorm.Open("mysql", "user:[email protected]/dbname?charset=utf8&parseTime=True&loc=Local")
db, err := gorm.Open("sqlite3", "../overlay.db")
if err != nil {
fmt.Println(err)
}
// You can also use an existing database connection handle
// dbSql, _ := sql.Open("postgres", "user=gorm dbname=gorm sslmode=disable")
// db, _ := gorm.Open("postgres", dbSql)
// Get database connection handle [*sql.DB](http://golang.org/pkg/database/sql/#DB)
db.DB()
// Then you could invoke `*sql.DB`'s functions with it
db.DB().Ping()
db.DB().SetMaxIdleConns(10)
db.DB().SetMaxOpenConns(100)
// Disable table name's pluralization
db.SingularTable(true)
// Create table (won't recreate if it exists)
db.CreateTable(&Overlay{})
// Drop table
// db.DropTable(&User{})
// Automating Migration
db.AutoMigrate(&Overlay{})
// db.AutoMigrate(&User{}, &Product{}, &Order{})
// Feel free to change your struct, AutoMigrate will keep your database up-to-date.
// AutoMigrate will ONLY add *new columns* and *new indexes*,
// WON'T update current column's type or delete unused columns, to protect your data.
// If the table is not existing, AutoMigrate will create the table automatically.
// o should be a pointer to an overlay struct
// o := Overlay{
// KeyId: "lg_dev/PER01/00043",
// VendorMode: "lg_dev",
// Type: "p",
// Description: "",
// Grp: "PER01",
// EId: "00041",
// AppID: "NBC",
// AlertPicUrl: "http://testurl.google.com",
// Freshness: 86400,
// NaggingEvent: 1,
// DateEntered: time.Now(),
// ExpireDate: time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC),
// CreateUser: "Mark",
// ContentId: "TEST-001-SE09-EP11",
// Series: "Big Bang Theory",
// Season: 9,
// Episode: 11,
// Channel: "WFOX",
// Vendor: "LG",
// }
i := Impl{}
i.InitDB()
i.InitSchema()
api := rest.NewApi()
api.Use(rest.DefaultDevStack...)
router, err := rest.MakeRouter(
rest.Get("/overlays", i.GetAllOverlays),
rest.Post("/overlays", i.PostOverlay),
rest.Get("/overlays/:id", i.GetOverlay),
rest.Put("/overlays/:id", i.PutOverlay),
rest.Delete("/overlays/:id", i.DeleteOverlay),
)
if err != nil {
log.Fatal(err)
}
api.SetApp(router)
log.Fatal(http.ListenAndServe(":8080", api.MakeHandler()))
}
开发者ID:MarkMarine,项目名称:overlayAPI,代码行数:76,代码来源:main.go
注:本文中的github.com/ant0ine/go-json-rest/rest.Delete函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论