Skip to content

Commit e0de8de

Browse files
committed
Merge branch 'master' of git://github.com/hoisie/web.go
2 parents 045bd47 + 4318eaa commit e0de8de

File tree

3 files changed

+17
-45
lines changed

3 files changed

+17
-45
lines changed

Readme.md

+15-44
Original file line numberDiff line numberDiff line change
@@ -6,75 +6,46 @@ web.go is the simplest way to write web applications in the Go programming langu
66

77
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:
88

9-
* routing to url handlers based on regular expressions
10-
* helper methods for rendering templates
11-
* web applications are compiled to native code, which means very fast page render times (order-of-magnitude improvement over python or ruby frameworks)
12-
13-
To use web.go, simply install it and import the "web" package. You then need to map url routes to function handlers using web.Get, web.Post, etc.. Finally, you need to call web.Run with the address of the host. (see the example below)
9+
* Routing to url handlers based on regular expressions
10+
* User sessions
11+
* Support for fastcgi and scgi
12+
* Web applications are compiled to native code. This means very fast execution and page render speed ( benchmarks coming soon :)
1413

1514
## Installation
1615

17-
1. Make sure you have the latest Go sources (hg sync in the go tree), and your environment is set up correctly: $GOROOT, $GOARCH, $GOBIN, etc.
18-
2. Checkout the code
16+
1. Make sure you have the a working Go environment. See the [install instructions](http://golang.org/doc/install.html)
17+
2. git clone git://github.com/hoisie/web.go.git
1918
3. cd web.go && make install
2019

2120
## Example
2221

2322
package main
2423

2524
import (
26-
"fmt"
2725
"web"
2826
)
2927

30-
func hello(val string) string {
31-
return fmt.Sprintf("hello %s", val)
32-
}
28+
func hello(val string) string { return "hello " + val }
3329

3430
func main() {
3531
web.Get("/(.*)", hello)
3632
web.Run("0.0.0.0:9999")
3733
}
3834

3935

40-
### Adding route handlers
41-
42-
We add a handler that matches the url path "/today". This will return the current url path.
43-
44-
package main
45-
46-
import (
47-
"fmt"
48-
"time"
49-
"web"
50-
)
51-
52-
func index() string {
53-
return "Welcome!"
54-
}
36+
To run the application, put the code in a file called hello.go and run:
5537

56-
func today() string {
57-
return fmt.Sprintf("The time is currently %s", time.LocalTime().Asctime())
58-
}
59-
60-
func main() {
61-
web.Get("/today", today)
62-
web.Get("/", index)
63-
web.Run("0.0.0.0:9999")
64-
}
65-
66-
Then stop the application and recompile it . You can point your browser to http://localhost:9999/today to see the new route.
38+
8g hello.go && 8l -o hello hello.8 && ./hello
6739

68-
## Roadmap
40+
You can point your browser to http://localhost:9999/world .
6941

70-
Future releases will support:
42+
## Documentation
7143

72-
* fastcgi and proxying support
73-
* an interface to write real-time applications (for long-polling)
74-
* a better template system
75-
* cookie-based sessions with storage
44+
More documentation, including a tutorial and API docs, is available on [web.go's home page](http://www.getwebgo.com)
7645

7746
## About
7847

79-
web.go was written by Michael Hoisie. Follow me on [Twitter](http://www.twitter.com/hoisie)!
48+
web.go was written by [Michael Hoisie](http://hoisie.com).
49+
50+
Follow me on [Twitter](http://www.twitter.com/hoisie)!
8051

examples/hello.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"web"
55
)
66

7-
func hello(val string) string { return "hello " + val }
7+
func hello(val string) string { return "hello " + val }
88

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

servefile.go

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ var contentByExt = map[string]string{
1111
".css": "text/css",
1212
".gif": "image/gif",
1313
".html": "text/html; charset=utf-8",
14+
".htm": "text/html; charset=utf-8",
1415
".jpg": "image/jpeg",
1516
".js": "application/x-javascript",
1617
".pdf": "application/pdf",

0 commit comments

Comments
 (0)