Skip to content
Permalink
Browse files

04-Web-Form add login form MethodPost handle

  • Loading branch information...
bonfy committed Sep 10, 2018
1 parent 3e42c84 commit f6e6b277400a03c9ceaa0231e2d3e5f794fa047f
Showing with 10 additions and 1 deletion.
  1. +10 −1 controller/home.go
@@ -1,6 +1,7 @@
package controller

import (
"fmt"
"net/http"

"github.com/bonfy/go-mega-code/vm"
@@ -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 sign in to comment.
You can’t perform that action at this time.