package module
Version: v0.1.0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2010 License: MIT Imports: 20 Imported by: 0



web.go is the simplest way to write web applications in the Go programming language.


web.go should be familiar to people who've developed websites with higher-level web frameworks like sinatra, pylons, or web.py. It is designed to be a lightweight web framework that doesn't impose any scaffolding on the user. Some features include:

  • Routing to url handlers based on regular expressions
  • User sessions
  • Support for fastcgi and scgi
  • Web applications are compiled to native code. This means very fast execution and page render speed ( benchmarks coming soon :)


  1. Make sure you have the a working Go environment. See the install instructions
  2. git clone git://github.com/hoisie/web.go.git
  3. cd web.go && make install


package main

import (

func hello(val string) string { return "hello " + val } 

func main() {
    web.Get("/(.*)", hello)

To run the application, put the code in a file called hello.go and run:

8g hello.go && 8l -o hello hello.8 && ./hello

You can point your browser to http://localhost:9999/world .


For a quickstart guide, check out web.go's home page

There is also a tutorial

If you use web.go, I'd greatly appreciate a quick message about what you're building with it. This will help me get a sense of usage patterns, and helps me focus development effors on features that people will actually use.


web.go was written by Michael Hoisie.

Follow me on Twitter!




This section is empty.


This section is empty.


func Delete

func Delete(route string, handler interface{})

Adds a handler for the 'DELETE' http method.

func Get

func Get(route string, handler interface{})

Adds a handler for the 'GET' http method.

func Post

func Post(route string, handler interface{})

Adds a handler for the 'POST' http method.

func Put

func Put(route string, handler interface{})

Adds a handler for the 'PUT' http method.

func Run

func Run(addr string)

runs the web application and serves http requests

func RunFcgi

func RunFcgi(addr string)

runs the web application by serving fastcgi requests

func RunScgi

func RunScgi(addr string)

runs the web application and serves scgi requests

func SetCookieSecret

func SetCookieSecret(key string)

func SetStaticDir

func SetStaticDir(dir string) os.Error

changes the location of the static directory. by default, it's under the 'static' folder of the directory containing the web application

func Urlencode

func Urlencode(data map[string]string) string


type Context

type Context struct {
	// contains filtered or unexported fields

func (*Context) Abort

func (ctx *Context) Abort(status int, body string)

func (*Context) GetSecureCookie

func (ctx *Context) GetSecureCookie(name string) (string, bool)

func (*Context) NotFound

func (ctx *Context) NotFound(message string)

func (*Context) Redirect

func (ctx *Context) Redirect(status int, url string)

func (*Context) SetCookie

func (ctx *Context) SetCookie(name string, value string, age int64)

Sets a cookie -- duration is the amount of time in seconds. 0 = forever

func (*Context) SetSecureCookie

func (ctx *Context) SetSecureCookie(name string, val string, age int64)

func (*Context) StartResponse

func (ctx *Context) StartResponse(status int)

func (*Context) Write

func (ctx *Context) Write(data []byte) (n int, err os.Error)

func (*Context) WriteString

func (ctx *Context) WriteString(content string)

type Request

type Request struct {
	Method     string    // GET, POST, PUT, etc.
	RawURL     string    // The raw URL given in the request.
	URL        *http.URL // Parsed URL.
	Proto      string    // "HTTP/1.0"
	ProtoMajor int       // 1
	ProtoMinor int       // 0
	Headers    map[string]string
	Body       io.Reader
	Close      bool
	Host       string
	Referer    string
	UserAgent  string
	Params     map[string][]string
	Cookies    map[string]string
	Files      map[string]filedata

func (*Request) HasFile

func (r *Request) HasFile(name string) bool

func (*Request) HasParam

func (r *Request) HasParam(name string) bool


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL