Skip to content

Commit

Permalink
04-Web-Form add login form MethodPost handle
Browse files Browse the repository at this point in the history
  • Loading branch information
bonfy committed Sep 10, 2018
1 parent 3e42c84 commit f6e6b27
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion controller/home.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package controller

import (
"fmt"
"net/http"

"github.com/bonfy/go-mega-code/vm"
Expand All @@ -24,5 +25,13 @@ func loginHandler(w http.ResponseWriter, r *http.Request) {
tpName := "login.html"
vop := vm.LoginViewModelOp{}
v := vop.GetVM()
templates[tpName].Execute(w, &v)
if r.Method == http.MethodGet {
templates[tpName].Execute(w, &v)
}
if r.Method == http.MethodPost {
r.ParseForm()
username := r.Form.Get("username")
password := r.Form.Get("password")
fmt.Fprintf(w, "Username:%s Password:%s", username, password)
}
}

0 comments on commit f6e6b27

Please # to comment.