Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(134)

Side by Side Diff: 2013/go4python/deco.go

Issue 87910043: code review 87910043: go.talks: fix build; add "// +build OMIT" to many samples (Closed)
Patch Set: diff -r 64c0764808ba https://code.google.com/p/go.talks Created 9 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « 2013/go-sreops/hello.go ('k') | 2013/go4python/decoex.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // +build OMIT
2
1 package main 3 package main
2 4
3 import ( 5 import (
4 "fmt" 6 "fmt"
5 "net/http" 7 "net/http"
6 ) 8 )
7 9
8 func authRequired(f http.HandlerFunc) http.HandlerFunc { 10 func authRequired(f http.HandlerFunc) http.HandlerFunc {
9 return func(w http.ResponseWriter, r *http.Request) { 11 return func(w http.ResponseWriter, r *http.Request) {
10 if r.FormValue("user") == "" { 12 if r.FormValue("user") == "" {
11 http.Error(w, "unknown user", http.StatusForbidden) 13 http.Error(w, "unknown user", http.StatusForbidden)
12 return 14 return
13 } 15 }
14 f(w, r) 16 f(w, r)
15 } 17 }
16 } 18 }
17 19
18 var hiHandler = authRequired( 20 var hiHandler = authRequired(
19 func(w http.ResponseWriter, r *http.Request) { 21 func(w http.ResponseWriter, r *http.Request) {
20 fmt.Fprintf(w, "Hi, %v", r.FormValue("user")) 22 fmt.Fprintf(w, "Hi, %v", r.FormValue("user"))
21 }, 23 },
22 ) 24 )
23 25
24 func main() { 26 func main() {
25 http.HandleFunc("/hi", hiHandler) 27 http.HandleFunc("/hi", hiHandler)
26 http.ListenAndServe(":8080", nil) 28 http.ListenAndServe(":8080", nil)
27 } 29 }
OLDNEW
« no previous file with comments | « 2013/go-sreops/hello.go ('k') | 2013/go4python/decoex.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b