当前位置: 首页>>代码示例>>Golang>>正文


Golang Router.HEAD方法代码示例

本文整理汇总了Golang中github.com/julienschmidt/httprouter.Router.HEAD方法的典型用法代码示例。如果您正苦于以下问题:Golang Router.HEAD方法的具体用法?Golang Router.HEAD怎么用?Golang Router.HEAD使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/julienschmidt/httprouter.Router的用法示例。


在下文中一共展示了Router.HEAD方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: SetupHTTP

// SetupHTTP attaches all the needed handlers to provide the HTTP API.
func (c *CloudAPI) SetupHTTP(mux *httprouter.Router) {
	baseRoute := "/" + c.ServiceInstance.UserAccount

	mux.NotFound = NotFound{}
	mux.MethodNotAllowed = MethodNotAllowed{}

	// keys
	keysRoute := baseRoute + "/keys"
	mux.GET(keysRoute, c.handler((*CloudAPI).handleListKeys))
	mux.POST(keysRoute, c.handler((*CloudAPI).handleCreateKey))

	// key
	keyRoute := keysRoute + "/:id"
	mux.GET(keyRoute, c.handler((*CloudAPI).handleGetKey))
	mux.DELETE(keyRoute, c.handler((*CloudAPI).handleDeleteKey))

	// images
	imagesRoute := baseRoute + "/images"
	mux.GET(imagesRoute, c.handler((*CloudAPI).handleListImages))

	// image
	imageRoute := imagesRoute + "/:id"
	mux.GET(imageRoute, c.handler((*CloudAPI).handleGetImage))
	mux.POST(imageRoute, c.handler((*CloudAPI).handleCreateImageFromMachine))
	mux.DELETE(imageRoute, c.handler((*CloudAPI).handleDeleteImage))

	// packages
	packagesRoute := baseRoute + "/packages"
	mux.GET(packagesRoute, c.handler((*CloudAPI).handleListPackages))

	// package
	packageRoute := packagesRoute + "/:id"
	mux.GET(packageRoute, c.handler((*CloudAPI).handleGetPackage))

	// machines
	machinesRoute := baseRoute + "/machines"
	mux.GET(machinesRoute, c.handler((*CloudAPI).handleListMachines))
	mux.HEAD(machinesRoute, c.handler((*CloudAPI).handleCountMachines))
	mux.POST(machinesRoute, c.handler((*CloudAPI).handleCreateMachine))

	// machine
	machineRoute := machinesRoute + "/:id"
	mux.GET(machineRoute, c.handler((*CloudAPI).handleGetMachine))
	mux.POST(machineRoute, c.handler((*CloudAPI).handleUpdateMachine))
	mux.DELETE(machineRoute, c.handler((*CloudAPI).handleDeleteMachine))

	// machine metadata
	machineMetadataRoute := machineRoute + "/metadata"
	mux.GET(machineMetadataRoute, c.handler((*CloudAPI).handleGetMachineMetadata))
	mux.POST(machineMetadataRoute, c.handler((*CloudAPI).handleUpdateMachineMetadata))
	mux.DELETE(machineMetadataRoute, c.handler((*CloudAPI).handleDeleteAllMachineMetadata))

	// machine metadata (individual key)
	machineMetadataKeyRoute := machineMetadataRoute + "/:key"
	mux.DELETE(machineMetadataKeyRoute, c.handler((*CloudAPI).handleDeleteMachineMetadata))

	// machine tags
	machineTagsRoute := machineRoute + "/tags"
	mux.GET(machineTagsRoute, c.handler((*CloudAPI).handleListMachineTags))
	mux.POST(machineTagsRoute, c.handler((*CloudAPI).handleAddMachineTags))
	mux.PUT(machineTagsRoute, c.handler((*CloudAPI).handleReplaceMachineTags))
	mux.DELETE(machineTagsRoute, c.handler((*CloudAPI).handleDeleteMachineTags))

	// machine tag
	machineTagRoute := machineTagsRoute + "/:tag"
	mux.GET(machineTagRoute, c.handler((*CloudAPI).handleGetMachineTag))
	mux.DELETE(machineTagRoute, c.handler((*CloudAPI).handleDeleteMachineTag))

	// machine firewall rules
	machineFWRulesRoute := machineRoute + "/fwrules"
	mux.GET(machineFWRulesRoute, c.handler((*CloudAPI).handleMachineFirewallRules))

	// machine NICs
	machineNICsRoute := machineRoute + "/nics"
	mux.GET(machineNICsRoute, c.handler((*CloudAPI).handleListNICs))
	mux.POST(machineNICsRoute, c.handler((*CloudAPI).handleAddNIC))

	// machine NIC
	machineNICRoute := machineNICsRoute + "/:mac"
	mux.GET(machineNICRoute, c.handler((*CloudAPI).handleGetNIC))
	mux.DELETE(machineNICRoute, c.handler((*CloudAPI).handleRemoveNIC))

	// firewall rules
	firewallRulesRoute := baseRoute + "/fwrules"
	mux.GET(firewallRulesRoute, c.handler((*CloudAPI).handleListFirewallRules))
	mux.POST(firewallRulesRoute, c.handler((*CloudAPI).handleCreateFirewallRule))

	// firewall rule
	firewallRuleRoute := firewallRulesRoute + "/:id"
	mux.GET(firewallRuleRoute, c.handler((*CloudAPI).handleGetFirewallRule))
	mux.POST(firewallRuleRoute, c.handler((*CloudAPI).handleUpdateFirewallRule))
	mux.DELETE(firewallRuleRoute, c.handler((*CloudAPI).handleDeleteFirewallRule))
	mux.POST(firewallRuleRoute+"/enable", c.handler((*CloudAPI).handleEnableFirewallRule))
	mux.POST(firewallRuleRoute+"/disable", c.handler((*CloudAPI).handleDisableFirewallRule))

	// networks
	networksRoute := baseRoute + "/networks"
	mux.GET(networksRoute, c.handler((*CloudAPI).handleListNetworks))

//.........这里部分代码省略.........
开发者ID:joyent,项目名称:gosdc,代码行数:101,代码来源:service_http.go


注:本文中的github.com/julienschmidt/httprouter.Router.HEAD方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。