本文整理汇总了Golang中github.com/julienschmidt/httprouter.Router.PUT方法的典型用法代码示例。如果您正苦于以下问题:Golang Router.PUT方法的具体用法?Golang Router.PUT怎么用?Golang Router.PUT使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/julienschmidt/httprouter.Router
的用法示例。
在下文中一共展示了Router.PUT方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: setupApi2
// Setup all routes for API v2
func setupApi2(router *httprouter.Router) {
router.GET("/api/v2", APIv2.ApiIndexVersion)
// Public Statistics
router.GET("/api/v2/websites", APIv2.ApiWebsites)
router.GET("/api/v2/websites/:url/status", APIv2.ApiWebsitesStatus)
router.GET("/api/v2/websites/:url/results", APIv2.ApiWebsitesResults)
// Authentication
router.POST("/api/v2/auth/login", APIv2.ApiAuthLogin)
router.GET("/api/v2/auth/logout", APIv2.ApiAuthLogout)
// Settings
router.PUT("/api/v2/settings/password", APIv2.ApiSettingsPassword)
router.PUT("/api/v2/settings/interval", APIv2.ApiSettingsInterval)
// Website Management
router.POST("/api/v2/websites/:url", APIv2.ApiWebsitesAdd)
router.PUT("/api/v2/websites/:url", APIv2.ApiWebsitesEdit)
router.DELETE("/api/v2/websites/:url", APIv2.ApiWebsitesDelete)
router.PUT("/api/v2/websites/:url/enabled", APIv2.ApiWebsitesEnabled)
router.PUT("/api/v2/websites/:url/visibility", APIv2.ApiWebsitesVisibility)
router.GET("/api/v2/websites/:url/notifications", APIv2.ApiWebsitesGetNotifications)
router.PUT("/api/v2/websites/:url/notifications", APIv2.ApiWebsitePutNotifications)
router.GET("/api/v2/websites/:url/check", APIv2.ApiWebsiteCheck)
}
示例2: Register
func (c *streamController) Register(router *httprouter.Router) {
router.PUT("/streams", basicAuth(c.handle(c.addToStream), c.authConfig))
router.POST("/streams/coalesce", basicAuth(c.handle(c.coalesceStreams), c.authConfig))
router.GET("/stream/:id", basicAuth(c.handle(c.getStream), c.authConfig))
log.Debug("Routes Registered")
}
示例3: Register
func (e profileEndpoint) Register(mux *httprouter.Router) {
mux.GET("/profile/:userId/displayname", jsonHandler(e.getDisplayName))
mux.PUT("/profile/:userId/displayname", jsonHandler(e.setDisplayName))
mux.GET("/profile/:userId/avatar_url", jsonHandler(e.getAvatarUrl))
mux.PUT("/profile/:userId/avatar_url", jsonHandler(e.setAvatarUrl))
mux.GET("/profile/:userId", jsonHandler(e.getProfile))
}
示例4: Register
func (c *streamController) Register(router *httprouter.Router) {
router.PUT("/streams", basicAuth(timeRequest(c.handle(c.addToStream), addToStreamTimer), c.authConfig))
router.DELETE("/streams", basicAuth(timeRequest(c.handle(c.removeFromStream), removeFromStreamTimer), c.authConfig))
router.POST("/streams/coalesce", basicAuth(timeRequest(c.handle(c.coalesceStreams), coalesceTimer), c.authConfig))
router.GET("/stream/:id", basicAuth(timeRequest(c.handle(c.getStream), getStreamTimer), c.authConfig))
log.Debug("Routes Registered")
}
示例5: 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)
}
示例6: addUsersHandlers
// addUsersHandlers add Users handler to router
func addUsersHandlers(router *httprouter.Router) {
// add user
router.POST("/users/:user", wrapHandler(usersAdd))
// get all users
router.GET("/users", wrapHandler(usersGetAll))
// get one user
router.GET("/users/:user", wrapHandler(usersGetOne))
// del an user
router.DELETE("/users/:user", wrapHandler(usersDel))
// change user password
router.PUT("/users/:user", wrapHandler(usersUpdate))
}
示例7: 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)
r.POST("/host/tags", h.UpdateTags)
return nil
}
示例8: SetupHTTP
// setupHTTP attaches all the needed handlers to provide the HTTP API.
func (m *Manta) SetupHTTP(mux *httprouter.Router) {
baseRoute := "/" + m.ServiceInstance.UserAccount
mux.NotFound = ErrNotFound
mux.MethodNotAllowed = ErrNotAllowed
mux.RedirectFixedPath = true
mux.RedirectTrailingSlash = true
mux.HandleMethodNotAllowed = true
// this particular route can't be handled by httprouter correctly due to its
// handling of positional parameters but we can't just pass in ErrNotAllowed
// either because it's the wrong type
handleNotAllowed := func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
w.WriteHeader(http.StatusMethodNotAllowed)
w.Header().Set("Content-Type", "text/plain; charset=UTF-8")
w.Write([]byte("Method is not allowed"))
}
mux.POST(baseRoute+"/stor", handleNotAllowed)
// storage APIs
// PutSnapLink and PutMetaData have the same route spec as other routes
// in this group, which isn't permitted by httprouter. We pick up the
// correct path in the handler
mux.PUT(baseRoute+"/stor/:dir", m.handler((*Manta).handleStorage)) // PutDirectory
mux.GET(baseRoute+"/stor/:dir", m.handler((*Manta).handleStorage)) // ListDirectory
mux.DELETE(baseRoute+"/stor/:dir", m.handler((*Manta).handleStorage)) // DeleteDirectory
mux.PUT(baseRoute+"/stor/:dir/:obj", m.handler((*Manta).handleStorage)) // PutObject
mux.GET(baseRoute+"/stor/:dir/:obj", m.handler((*Manta).handleStorage)) // GetObject
mux.DELETE(baseRoute+"/stor/:dir/:obj", m.handler((*Manta).handleStorage)) // DeleteObject
// job APIs
mux.POST(baseRoute+"/jobs", m.handler((*Manta).handleJobs)) // CreateJob
mux.POST(baseRoute+"/jobs/:id/live/in", m.handler((*Manta).handleJobs)) // AddJobInputs
mux.POST(baseRoute+"/jobs/:id/live/in/end", m.handler((*Manta).handleJobs)) // EndJobInput
mux.POST(baseRoute+"/jobs/:id/live/cancel", m.handler((*Manta).handleJobs)) // CancelJob
mux.GET(baseRoute+"/jobs", m.handler((*Manta).handleJobs)) // ListJobs
mux.GET(baseRoute+"/jobs/:id/live/status", m.handler((*Manta).handleJobs)) // GetJob
mux.GET(baseRoute+"/jobs/:id/live/out", m.handler((*Manta).handleJobs)) // GetJobOutput
mux.GET(baseRoute+"/jobs/:id/live/in", m.handler((*Manta).handleJobs)) // GetJobInput
mux.GET(baseRoute+"/jobs/:id/live/fail", m.handler((*Manta).handleJobs)) // GetJobFailures
mux.GET(baseRoute+"/jobs/:id/live/err", m.handler((*Manta).handleJobs)) // GetJobErrors
}
示例9: LoadRoutes
func (self *CommandModule) LoadRoutes(router *httprouter.Router) error {
router.GET(`/api/commands/list`, func(w http.ResponseWriter, req *http.Request, params httprouter.Params) {
util.Respond(w, http.StatusOK, self.Commands, nil)
})
router.PUT(`/api/commands/run/:name`, func(w http.ResponseWriter, req *http.Request, params httprouter.Params) {
name := params.ByName(`name`)
if command, ok := self.Commands[name]; ok {
if results, err := command.Execute(); err == nil {
util.Respond(w, http.StatusOK, results, nil)
} else {
util.Respond(w, http.StatusOK, results, nil)
}
} else {
util.Respond(w, http.StatusNotFound, nil, fmt.Errorf("Cannot find a command called '%s'", name))
}
})
return nil
}
示例10: setup
func setup(router *httprouter.Router) {
router.GET("/api/user", controller.UserGet)
router.GET("/api/user/:id", controller.UserGet)
router.GET("/api/redis/user/:id", controller.RedisUserGet)
router.GET("/api/redis/user", controller.RedisUserGet)
router.PUT("/api/user", controller.UserUpsert)
router.PUT("/api/user/:id", controller.UserUpsert)
router.PUT("/api/redis/user/:id", controller.RedisUserWrite)
router.DELETE("/api/user", controller.UserDelete)
router.DELETE("/api/user/:id", controller.UserDelete)
router.PATCH("/api/user/:id", controller.UserUpdate)
// TOTEC
router.GET("/api/musics", controller.MusicGet)
router.GET("/api/musics/:id", controller.MusicGet)
router.POST("/api/musics", controller.MusicUpsert)
router.PUT("/api/musics/:id", controller.MusicUpsert)
router.DELETE("/api/musics/:id", controller.MusicDelete)
router.POST("/api/musics/:id/play", controller.HistoryUpsert)
}
示例11: Register
func (e roomsEndpoint) Register(mux *httprouter.Router) {
mux.POST("/rooms/:roomId/send/:eventType", jsonHandler(e.sendMessage))
mux.PUT("/rooms/:roomId/send/:eventType/:txn", jsonHandler(e.sendMessage))
mux.PUT("/rooms/:roomId/state/:eventType", e.handlePutState)
mux.PUT("/rooms/:roomId/state/:eventType/:stateKey", e.handlePutState)
// mux.GET("/rooms/:roomId/state/:eventType", jsonHandler(dummy))
// mux.GET("/rooms/:roomId/state/:eventType/:stateKey", jsonHandler(dummy))
mux.POST("/rooms/:roomId/invite", jsonHandler(e.doInvite))
mux.POST("/rooms/:roomId/kick", jsonHandler(e.doKick))
mux.POST("/rooms/:roomId/ban", jsonHandler(e.doBan))
mux.POST("/rooms/:roomId/join", jsonHandler(e.doJoin))
mux.POST("/rooms/:roomId/knock", jsonHandler(e.doKnock))
mux.POST("/rooms/:roomId/leave", jsonHandler(e.doLeave))
mux.GET("/rooms/:roomId/messages", jsonHandler(e.getMessages))
// mux.GET("/rooms/:roomId/members", jsonHandler(dummy))
// mux.GET("/rooms/:roomId/state", jsonHandler(dummy))
// mux.PUT("/rooms/:roomId/typing/:userId", jsonHandler(dummy))
mux.GET("/rooms/:roomId/initialSync", jsonHandler(e.doInitialSync))
mux.POST("/join/:roomAliasOrId", jsonHandler(e.doWildcardJoin))
mux.POST("/createRoom", jsonHandler(e.createRoom))
}
示例12: RegisterRouter
// RegisterRouter registers a router onto the Server.
func (s *Server) RegisterRouter(router *httprouter.Router) {
router.GET("/ping", s.ping)
router.GET("/customer", s.getCustomers)
router.POST("/customer", s.createCustomer)
router.GET("/customer/:customerID", s.getCustomer)
router.PUT("/customer/:customerID", s.updateCustomer)
router.DELETE("/customer/:customerID", s.deleteCustomer)
router.GET("/product", s.getProducts)
router.POST("/product", s.createProduct)
router.GET("/product/:productID", s.getProduct)
router.PUT("/product/:productID", s.updateProduct)
router.DELETE("/product/:productID", s.deleteProduct)
router.GET("/order", s.getOrders)
router.POST("/order", s.createOrder)
router.GET("/order/:orderID", s.getOrder)
router.PUT("/order/:orderID", s.updateOrder)
router.DELETE("/order/:orderID", s.deleteOrder)
router.POST("/order/:orderID/product", s.addProductToOrder)
}
示例13: PUT
func PUT(r *httprouter.Router, path string, handler Handler) {
r.PUT(path, handle(handler))
}
示例14: Register
func (e eventsEndpoint) Register(mux *httprouter.Router) {
mux.GET("/events", jsonHandler(e.getEvents))
mux.PUT("/events/:eventId", jsonHandler(e.getSingleEvent))
mux.GET("/initialSync", jsonHandler(e.getInitialSync))
mux.PUT("/publicRooms", jsonHandler(e.getPublicRooms))
}
示例15: setupApi1
// Setup all routes for API v1
func setupApi1(router *httprouter.Router) {
router.GET("/api/v1/*all", APIv1.ApiIndexVersion)
router.POST("/api/v1/*all", APIv1.ApiIndexVersion)
router.PUT("/api/v1/*all", APIv1.ApiIndexVersion)
router.DELETE("/api/v1/*all", APIv1.ApiIndexVersion)
}