Mercurial > mercurial > hgweb_golang.cgi
diff src/entai_app/entai_app.go @ 5:e4066309b04f
refactoring.
author | pyon@macmini |
---|---|
date | Sun, 23 Oct 2016 14:00:39 +0900 |
parents | ca866a38a6a0 |
children | f4ba4cfb09fd |
line wrap: on
line diff
--- a/src/entai_app/entai_app.go Tue Oct 18 21:28:25 2016 +0900 +++ b/src/entai_app/entai_app.go Sun Oct 23 14:00:39 2016 +0900 @@ -1,6 +1,6 @@ /****************************************************************************/ /* Entai_app.go */ -/* Last Change: 2016-10-15 Sat 19:29:24. */ +/* Last Change: 2016-10-23 Sun 13:23:32. */ /* By T.Mutoh */ /****************************************************************************/ @@ -13,6 +13,7 @@ "fmt" "io" "log" + "net/http" "os" "strconv" "strings" @@ -96,9 +97,9 @@ // Server-mode ( not implement ) case *s : - *p = 8080 - fmt.Fprint( os.Stderr, "server mode is not implemented.\n" ) - os.Exit( 1 ) + s := fmt.Sprintf( "localhost:%d", *p ) + http.HandleFunc( "/", httpHandler ) + log.Fatal( http.ListenAndServe( s, nil ) ) // Intaractive-mode case *d : @@ -239,6 +240,16 @@ return s } +func httpHandler( w http.ResponseWriter, r *http.Request ) { + fmt.Fprintf( w, "RemoteAddr: %q\n", r.RemoteAddr ) + if err := r.ParseForm(); err != nil { + log.Print( err ) + } + for k, v := range r.Form { + fmt.Fprintf( w, "%q: %q\n", k, v ) + } +} + func printTile() { fmt.Fprint( os.Stderr, "\n==================================================\n" ) fmt.Fprintf( os.Stderr, " Entai_app ver %s ( 2016.10.19 ) - since 2016\n", ver )