# HG changeset patch # User pyon@macmini # Date 1477198839 -32400 # Node ID e4066309b04fbd6c46cd032e41e3b7aa65421a8e # Parent 4c6bfc90d75c5faf92c923a747752992f684f095 refactoring. diff -r 4c6bfc90d75c -r e4066309b04f src/entai/entai.go --- a/src/entai/entai.go Tue Oct 18 21:28:25 2016 +0900 +++ b/src/entai/entai.go Sun Oct 23 14:00:39 2016 +0900 @@ -1,6 +1,6 @@ /****************************************************************************/ /* Entai.go ( ver 0.3 ) */ -/* Last Change: 2016-10-18 Tue 21:26:15. */ +/* Last Change: 2016-10-22 Sat 15:06:28. */ /* By T.Mutoh */ /****************************************************************************/ @@ -68,8 +68,7 @@ return "Entai....." } -func ( e Entai ) GetRates() string { - var str string +func ( e Entai ) GetRates() ( str string ) { for i, n := range nyds { str += fmt.Sprintf( " (H%d) ", n.Year() - 1988 ) str += fmt.Sprintf( "%s :%4.1f / %4.1f\n", n.Format("2006.01.02"), rate0s[i] * 100, rate1s[i] * 100 ) diff -r 4c6bfc90d75c -r e4066309b04f src/entai_app/entai_app.go --- 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 )