Skip to content

Commit 95980ff

Browse files
committed
Added ctx.Redirect and request.HasParam methods
1 parent e0de8de commit 95980ff

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

request.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,8 @@ func (r *Request) ParseCookies() (err os.Error) {
172172

173173
return nil
174174
}
175+
176+
func (r *Request) HasParam(name string) bool {
177+
_, ok := r.Params[name]
178+
return ok
179+
}

web.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ func (ctx *Context) Abort(status int, body string) {
3535
ctx.responseStarted = true
3636
}
3737

38+
func (ctx *Context) Redirect(status int, url string) {
39+
//note := "<a href=\"%v\">" + statusText[code] + "</a>.\n"
40+
41+
ctx.Conn.SetHeader("Location", url, true)
42+
ctx.Conn.StartResponse(status)
43+
ctx.Conn.WriteString("")
44+
ctx.responseStarted = true
45+
}
3846
//Sets a cookie -- duration is the amount of time in seconds. 0 = forever
3947
func (ctx *Context) SetCookie(name string, value string, duration int64) {
4048
if duration == 0 {

0 commit comments

Comments
 (0)