ответ на веб-страницу с JavaScript в Голанге - PullRequest
0 голосов
/ 15 сентября 2018

У меня есть веб-страница с формами логина и пароля Если логин или пароль неверны, как я могу ответить с помощью функций javascript alert () или console.log () в golang

<body>
    <!-- LOGIN FORM -->
    <div class="login-page">
        <div class="form">
          <form class="login-form"action="/login" method="POST">
            <input type="text"   name="username"   placeholder="username"/>
            <input type="password" name="password" placeholder="password"/>
            <button type="submit" id="send" value="Login">Login</button>
          </form>
        </div>
      </div>
</body>

GOLANG

func (c *AuthenticationControllers) AdminLogin() http.HandlerFunc {
    return func(w http.ResponseWriter, r *http.Request) {

        switch r.Method {
        case "GET":
            http.ServeFile(w, r, "C:/Projects/Go/src/github.com/AlifElectronicQueue/web/template/login.html")
        case "POST":

            //********AUTHENTICATION PROCESS*********//
            if loginAns {
                //Some code
                http.Redirect(w, r, "/admin/applications", 302)

            }  else {
                http.Redirect(w, r, "/login", 302)
                http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
            } 
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...