Skip to content

Commit 2f7d97d

Browse files
committed
Added web.Urlencode method
1 parent 95980ff commit 2f7d97d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

web.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,18 @@ func SetStaticDir(dir string) os.Error {
345345
return nil
346346
}
347347

348+
func Urlencode ( data map[string]string ) string {
349+
var buf bytes.Buffer;
350+
for k,v := range ( data ) {
351+
buf.WriteString ( http.URLEscape(k) )
352+
buf.WriteByte('=' )
353+
buf.WriteString ( http.URLEscape(v) )
354+
buf.WriteByte('&' )
355+
}
356+
s := buf.String()
357+
return s[0:len(s) - 1]
358+
}
359+
348360
//copied from go's http package, because it's not public
349361
var statusText = map[int]string{
350362
http.StatusContinue: "Continue",

0 commit comments

Comments
 (0)