-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Victor Castell
committed
Oct 22, 2011
1 parent
70a5fe6
commit 301e3e2
Showing
3 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package main | ||
|
||
import ( | ||
"mango" | ||
"cats_middleware" | ||
"http" | ||
"os" | ||
"io/ioutil" | ||
) | ||
|
||
func Hello(env mango.Env) (mango.Status, mango.Headers, mango.Body) { | ||
env.Logger().Println("Got a", env.Request().Method, "request for", env.Request().RawURL) | ||
|
||
response, err := http.Get("http://www.weddinggalleryweb.com/") | ||
if err != nil { | ||
env.Logger().Printf("%s", err) | ||
os.Exit(1) | ||
} | ||
defer response.Body.Close() | ||
|
||
contents, err := ioutil.ReadAll(response.Body) | ||
if err != nil { | ||
env.Logger().Printf("%s", err) | ||
os.Exit(1) | ||
} | ||
|
||
return 200, mango.Headers{}, mango.Body(contents) | ||
} | ||
|
||
func main() { | ||
|
||
stack := new(mango.Stack) | ||
stack.Address = ":3000" | ||
|
||
// Initialize our cats middleware with our list of cat_images | ||
cat_images := []string{"http://images.cheezburger.com/completestore/2010/7/4/9440dc57-52a6-4122-9ab3-efd4daa0ff60.jpg", "http://images.icanhascheezburger.com/completestore/2008/12/10/128733944185267668.jpg"} | ||
cats_middleware := cats.Cats(cat_images) | ||
|
||
stack.Middleware(cats_middleware) // Include the Cats middleware in our stack | ||
|
||
stack.Run(Hello) | ||
} |