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


Golang gin.Engine类代码示例

本文整理汇总了Golang中github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin.Engine的典型用法代码示例。如果您正苦于以下问题:Golang Engine类的具体用法?Golang Engine怎么用?Golang Engine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Start

// Start the server. Adds the handler to the router and sets everything up.
func (this *WebSocketServer) Start(config *ServerConfig, router *gin.Engine) {

	this.config = config

	this.upgrader = websocket.Upgrader{
		ReadBufferSize: int(config.WebSocket.ReadBufferSize),
		// TODO Will this be enough for massive "get blockchain" requests?
		WriteBufferSize: int(config.WebSocket.WriteBufferSize),
	}
	this.upgrader.CheckOrigin = func(r *http.Request) bool { return true }
	router.GET(config.WebSocket.WebSocketEndpoint, this.handleFunc)
	this.running = true
}
开发者ID:ZhuZhengyi,项目名称:eris-db,代码行数:14,代码来源:websocket.go

示例2: request

func request(server *gin.Engine, options requestOptions) *httptest.ResponseRecorder {
	if options.Method == "" {
		options.Method = "GET"
	}

	w := httptest.NewRecorder()
	req, err := http.NewRequest(options.Method, options.URL, options.Body)

	if options.Headers != nil {
		for key, value := range options.Headers {
			req.Header.Set(key, value)
		}
	}

	server.ServeHTTP(w, req)

	if err != nil {
		panic(err)
	}

	return w
}
开发者ID:ZhuZhengyi,项目名称:eris-db,代码行数:22,代码来源:cors_test.go

示例3: Start

func (this *ScumbagServer) Start(sc *server.ServerConfig, g *gin.Engine) {
	g.GET("/scumbag", func(c *gin.Context) {
		c.String(200, "Scumbag")
	})
	this.running = true
}
开发者ID:ZhuZhengyi,项目名称:eris-db,代码行数:6,代码来源:scumbag.go

示例4: Start

// Starting the server means registering all the handlers with the router.
func (this *RestServer) Start(config *server.ServerConfig, router *gin.Engine) {
	// Accounts
	router.GET("/accounts", parseSearchQuery, this.handleAccounts)
	router.GET("/accounts/:address", addressParam, this.handleAccount)
	router.GET("/accounts/:address/storage", addressParam, this.handleStorage)
	router.GET("/accounts/:address/storage/:key", addressParam, keyParam, this.handleStorageAt)
	// Blockchain
	router.GET("/blockchain", this.handleBlockchainInfo)
	router.GET("/blockchain/chain_id", this.handleChainId)
	router.GET("/blockchain/genesis_hash", this.handleGenesisHash)
	router.GET("/blockchain/latest_block_height", this.handleLatestBlockHeight)
	router.GET("/blockchain/latest_block", this.handleLatestBlock)
	router.GET("/blockchain/blocks", parseSearchQuery, this.handleBlocks)
	router.GET("/blockchain/block/:height", heightParam, this.handleBlock)
	// Consensus
	router.GET("/consensus", this.handleConsensusState)
	router.GET("/consensus/validators", this.handleValidatorList)
	// Events
	router.POST("/event_subs", this.handleEventSubscribe)
	router.GET("/event_subs/:id", this.handleEventPoll)
	router.DELETE("/event_subs/:id", this.handleEventUnsubscribe)
	// NameReg
	router.GET("/namereg", parseSearchQuery, this.handleNameRegEntries)
	router.GET("/namereg/:key", nameParam, this.handleNameRegEntry)
	// Network
	router.GET("/network", this.handleNetworkInfo)
	router.GET("/network/client_version", this.handleClientVersion)
	router.GET("/network/moniker", this.handleMoniker)
	router.GET("/network/listening", this.handleListening)
	router.GET("/network/listeners", this.handleListeners)
	router.GET("/network/peers", this.handlePeers)
	router.GET("/network/peers/:address", peerAddressParam, this.handlePeer)
	// Tx related (TODO get txs has still not been implemented)
	router.POST("/txpool", this.handleBroadcastTx)
	router.GET("/txpool", this.handleUnconfirmedTxs)
	// Code execution
	router.POST("/calls", this.handleCall)
	router.POST("/codecalls", this.handleCallCode)
	// Unsafe
	router.GET("/unsafe/pa_generator", this.handleGenPrivAcc)
	router.POST("/unsafe/txpool", parseTxModifier, this.handleTransact)
	router.POST("/unsafe/namereg/txpool", this.handleTransactNameReg)
	router.POST("/unsafe/tx_signer", this.handleSignTx)
	this.running = true
}
开发者ID:alexandrev,项目名称:eris-db,代码行数:46,代码来源:restServer.go

示例5: Start

// Start adds the rpc path to the router.
func (this *JsonRpcServer) Start(config *server.ServerConfig, router *gin.Engine) {
	router.POST(config.HTTP.JsonRpcEndpoint, this.handleFunc)
	this.running = true
}
开发者ID:readevalprint,项目名称:eris-db,代码行数:5,代码来源:json_service.go

示例6: Start

// Start the server.
func (this *ServerServer) Start(config *server.ServerConfig, router *gin.Engine) {
	router.POST("/server", this.handleFunc)
	this.running = true
}
开发者ID:uledger,项目名称:eris-db,代码行数:5,代码来源:http.go


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