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


Golang Context.Param方法代码示例

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


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

示例1: getEpisode

//
// GET /library/episode/:id
//
func getEpisode(c *echo.Context) error {
	id, err := strconv.ParseUint(c.Param("id"), 10, 64)
	if err != nil {
		return c.NoContent(400)
	}

	return c.JSON(200, store.GetEpisode(id))
}
开发者ID:Castcloud,项目名称:castcloud-go-server,代码行数:11,代码来源:episodes.go

示例2: updateUser

func updateUser(c *echo.Context) error {
	u := new(user)
	if err := c.Bind(u); err != nil {
		return err
	}
	id, _ := strconv.Atoi(c.Param("id"))
	users[id].Name = u.Name
	return c.JSON(http.StatusOK, users[id])
}
开发者ID:Castcloud,项目名称:castcloud-go-server,代码行数:9,代码来源:server.go

示例3: removeLabel

//
// DELETE /library/labels/:id
//
func removeLabel(c *echo.Context) error {
	id, err := strconv.ParseUint(c.Param("id"), 10, 64)
	if err != nil {
		return c.NoContent(400)
	}

	user := c.Get("user").(*User)
	return store.RemoveLabel(id, user.ID)
}
开发者ID:Castcloud,项目名称:castcloud-go-server,代码行数:12,代码来源:labels.go

示例4: removeCast

//
// DELETE /library/casts/:id
//
func removeCast(c *echo.Context) error {
	id, err := strconv.ParseUint(c.Param("id"), 10, 64)
	if err != nil {
		return c.NoContent(400)
	}

	user := c.Get("user").(*User)
	user, err = store.RemoveSubscription(user.ID, id)
	authCache.set(c.Get("token").(string), user)
	return err
}
开发者ID:Castcloud,项目名称:castcloud-go-server,代码行数:14,代码来源:casts.go

示例5: removeSetting

//
// DELETE /account/settings/:id
//
func removeSetting(c *echo.Context) error {
	id, err := strconv.ParseUint(c.Param("id"), 10, 64)
	if err != nil {
		return c.NoContent(400)
	}

	user := c.Get("user").(*User)
	err = store.RemoveSetting(id, user.ID)
	if err == ErrSettingNotFound {
		return c.String(404, "Setting not found")
	}

	return err
}
开发者ID:Castcloud,项目名称:castcloud-go-server,代码行数:17,代码来源:account.go

示例6: renameCast

//
// PUT /library/casts/:id
//
func renameCast(c *echo.Context) error {
	id, err := strconv.ParseUint(c.Param("id"), 10, 64)
	if err != nil {
		return c.NoContent(400)
	}

	cast := store.GetCast(id)
	if cast == nil {
		return c.String(404, "Cast not found")
	}

	prev := cast.Name
	cast.Name = form(c, "name")
	if cast.Name != prev {
		return store.SaveCast(cast)
	}

	return nil
}
开发者ID:Castcloud,项目名称:castcloud-go-server,代码行数:22,代码来源:casts.go

示例7: updateLabel

//
// PUT /library/labels/:id
//
func updateLabel(c *echo.Context) error {
	id, err := strconv.ParseUint(c.Param("id"), 10, 64)
	if err != nil {
		return c.NoContent(400)
	}

	label := store.GetLabel(id)
	if label == nil {
		return c.String(404, "Label not found")
	}

	if name := form(c, "name"); name != "" {
		label.Name = name
	}
	if content := form(c, "content"); content != "" {
		label.Content = content
	}
	if expanded := form(c, "expanded"); expanded != "" {
		label.Expanded = expanded == "true"
	}

	user := c.Get("user").(*User)
	return store.SaveLabel(label, user.ID)
}
开发者ID:Castcloud,项目名称:castcloud-go-server,代码行数:27,代码来源:labels.go

示例8: deleteUser

func deleteUser(c *echo.Context) error {
	id, _ := strconv.Atoi(c.Param("id"))
	delete(users, id)
	return c.NoContent(http.StatusNoContent)
}
开发者ID:Castcloud,项目名称:castcloud-go-server,代码行数:5,代码来源:server.go

示例9: getUser

func getUser(c *echo.Context) error {
	id, _ := strconv.Atoi(c.Param("id"))
	return c.JSON(http.StatusOK, users[id])
}
开发者ID:Castcloud,项目名称:castcloud-go-server,代码行数:4,代码来源:server.go


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