本文整理汇总了Golang中github.com/bkand1909/song-getter/Godeps/_workspace/src/github.com/astaxie/beego/context.Context.WriteString方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.WriteString方法的具体用法?Golang Context.WriteString怎么用?Golang Context.WriteString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/bkand1909/song-getter/Godeps/_workspace/src/github.com/astaxie/beego/context.Context
的用法示例。
在下文中一共展示了Context.WriteString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Handler
// beego filter handler for serve captcha image
func (c *Captcha) Handler(ctx *context.Context) {
var chars []byte
id := path.Base(ctx.Request.RequestURI)
if i := strings.Index(id, "."); i != -1 {
id = id[:i]
}
key := c.key(id)
if len(ctx.Input.Query("reload")) > 0 {
chars = c.genRandChars()
if err := c.store.Put(key, chars, c.Expiration); err != nil {
ctx.Output.SetStatus(500)
ctx.WriteString("captcha reload error")
beego.Error("Reload Create Captcha Error:", err)
return
}
} else {
if v, ok := c.store.Get(key).([]byte); ok {
chars = v
} else {
ctx.Output.SetStatus(404)
ctx.WriteString("captcha not found")
return
}
}
img := NewImage(chars, c.StdWidth, c.StdHeight)
if _, err := img.WriteTo(ctx.ResponseWriter); err != nil {
beego.Error("Write Captcha Image Error:", err)
}
}
示例2: exception
// show error string as simple text message.
// if error string is empty, show 500 error as default.
func exception(errcode string, ctx *context.Context) {
code, err := strconv.Atoi(errcode)
if err != nil {
code = 503
}
if h, ok := ErrorMaps[errcode]; ok {
executeError(h, ctx, code)
return
} else if h, ok := ErrorMaps["503"]; ok {
executeError(h, ctx, code)
return
} else {
ctx.ResponseWriter.WriteHeader(code)
ctx.WriteString(errcode)
}
}
示例3: beegoFinishRouter2
func beegoFinishRouter2(ctx *context.Context) {
ctx.WriteString("|FinishRouter2")
}
示例4: beegoAfterExec2
func beegoAfterExec2(ctx *context.Context) {
ctx.WriteString("|AfterExec2")
}
示例5: beegoBeforeExec2
func beegoBeforeExec2(ctx *context.Context) {
ctx.WriteString("|BeforeExec2")
}
示例6: beegoBeforeRouter2
func beegoBeforeRouter2(ctx *context.Context) {
ctx.WriteString("|BeforeRouter2")
}
示例7: beegoFilterFunc
func beegoFilterFunc(ctx *context.Context) {
ctx.WriteString("hello")
}