本文整理汇总了Golang中github.com/Castcloud/castcloud-go-server/Godeps/_workspace/src/github.com/labstack/echo.Context.String方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.String方法的具体用法?Golang Context.String怎么用?Golang Context.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/Castcloud/castcloud-go-server/Godeps/_workspace/src/github.com/labstack/echo.Context
的用法示例。
在下文中一共展示了Context.String方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: addLabel
//
// POST /library/labels
//
func addLabel(c *echo.Context) error {
name := strings.TrimPrefix(form(c, "name"), "label/")
if name == "" {
return c.String(400, "Name too short")
}
label := Label{
Name: name,
Content: form(c, "content"),
Expanded: form(c, "expanded") == "true",
}
user := c.Get("user").(*User)
err := store.SaveLabel(&label, user.ID)
if err == ErrLabelExists {
return c.String(409, "Existing label")
} else if err != nil {
return err
}
return c.JSON(200, addedLabel{
ID: label.ID,
Name: label.Name,
})
}
示例2: 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
}
示例3: 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
}
示例4: addCast
//
// POST /library/casts
//
func addCast(c *echo.Context) error {
user := c.Get("user").(*User)
url := form(c, "feedurl")
cast := store.GetCastByURL(url)
if cast == nil {
cast = <-crawl.fetch(url)
if cast == nil {
return c.String(500, "Could not fetch feed")
}
}
user, err := store.AddSubscription(user.ID, cast.ID)
if err != nil && err != ErrSubscriptionExists {
return err
}
authCache.set(c.Get("token").(string), user)
return c.JSON(200, cast)
}
示例5: 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)
}
示例6: hello
// Handler
func hello(c *echo.Context) error {
return c.String(http.StatusOK, "Hello, World!\n")
}