當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Context.Request方法代碼示例

本文整理匯總了Golang中github.com/Castcloud/castcloud-go-server/Godeps/_workspace/src/github.com/labstack/echo.Context.Request方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.Request方法的具體用法?Golang Context.Request怎麽用?Golang Context.Request使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/Castcloud/castcloud-go-server/Godeps/_workspace/src/github.com/labstack/echo.Context的用法示例。


在下文中一共展示了Context.Request方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: getNewEpisodes

//
// GET /library/newepisodes
//
func getNewEpisodes(c *echo.Context) error {
	now := time.Now().Unix()
	user := c.Get("user").(*User)
	since := c.Request().URL.Query().Get("since")
	if since == "" {
		return c.JSON(200, newEpisodes{
			Timestamp: now,
			Episodes:  store.GetEpisodesSince(0, user.Subscriptions),
		})
	}

	ts, err := strconv.ParseInt(since, 10, 64)
	if err != nil {
		return c.NoContent(400)
	}

	return c.JSON(200, newEpisodes{
		Timestamp: now,
		Episodes:  store.GetEpisodesSince(ts, user.Subscriptions),
	})
}
開發者ID:Castcloud,項目名稱:castcloud-go-server,代碼行數:24,代碼來源:episodes.go

示例2: getEvents

//
// GET /library/events
//
func getEvents(c *echo.Context) error {
	now := time.Now().Unix()
	var err error
	var ts uint64
	since := c.Request().URL.Query().Get("since")
	if since != "" {
		ts, err = strconv.ParseUint(since, 10, 64)
		if err != nil {
			return c.NoContent(400)
		}
	}

	user := c.Get("user").(*User)
	uuid := ""
	excludeSelf := c.Request().URL.Query().Get("exclude_self")
	if excludeSelf == "true" {
		uuid = c.Get("uuid").(string)
	}

	return c.JSON(200, events{
		Timestamp: now,
		Events:    store.GetEvents(user.ID, ts, uuid),
	})
}
開發者ID:Castcloud,項目名稱:castcloud-go-server,代碼行數:27,代碼來源:events.go

示例3: form

func form(c *echo.Context, key string) string {
	return c.Request().FormValue(key)
}
開發者ID:Castcloud,項目名稱:castcloud-go-server,代碼行數:3,代碼來源:util.go


注:本文中的github.com/Castcloud/castcloud-go-server/Godeps/_workspace/src/github.com/labstack/echo.Context.Request方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。