github.com/serge-v/zero@v1.0.2-0.20220911142406-af4b6a19e68a/examples/how-to-user-registration/home.html (about)

     1  <!doctype html>
     2  <html lang="en">
     3  <head>
     4      <title>golang-user-registration</title>
     5      <link rel="stylesheet" href="main.css">
     6      <meta name="viewport" content="width=device-width,initial-scale=1">
     7  </head>
     8  <body>
     9  
    10  <h1>How to make user registration in golang app</h1>
    11  
    12  <time>17 September 2021</time>
    13  <p>In this example we will create user registration for the website.</p>
    14  
    15  <h2>Demo</h2>
    16  You can view a demonstration of this example on <a href="/demo">demo page</a>.
    17  
    18  <h2>Create skeleton application</h2>
    19  We create http server with empty handlers. I added comments what each handler should do.
    20  <br>
    21  <br>
    22  <gocode>
    23  package main
    24  
    25  import "net/http"
    26  
    27  func main() {
    28  	http.HandleFunc("/", handleHomePage)
    29  	http.HandleFunc("/signup", handleSignup)
    30  	http.HandleFunc("/register", handleRegister)
    31  	http.HandleFunc("/confirm", handleConfirm)
    32  	http.HandleFunc("/signin", handleSignin)
    33  	http.HandleFunc("/login", handleLogin)
    34  
    35  	if err := http.ListenAndServe("127.0.0.1:8098", nil); err != nil {
    36  		log.Fatal(err)
    37  	}
    38  }
    39  
    40  // handleHomePage should do:
    41  // - contains links to Signup and Signin pages
    42  func handleHomePage(w http.ResponseWriter, r *http.Request) {
    43  }
    44  
    45  // handleSignup should do:
    46  // - show signup form to the user
    47  // - on button click send form to the /register handler
    48  func handleSignup(w http.ResponseWriter, r *http.Request) {
    49  }
    50  
    51  // handleRegister should do:
    52  // - create non-active user record in DB with random hash
    53  // - send confirmation link by email to the user
    54  func handleRegister(w http.ResponseWriter, r *http.Request) {
    55  }
    56  
    57  // handleConfirm should do:
    58  // - if random hash matches activate the user
    59  func handleConfirm(w http.ResponseWriter, r *http.Request) {
    60  }
    61  
    62  // handleSignin should do:
    63  // - show login form to the user
    64  func handleSignin(w http.ResponseWriter, r *http.Request) {
    65  }
    66  
    67  // handleLogin should do:
    68  // - login active user
    69  func handleLogin(w http.ResponseWriter, r *http.Request) {
    70  }
    71  
    72  </gocode>
    73  
    74  <h2>Implementing handleHomePage</h2>
    75  
    76  Homepage should contain 2 links to the user:
    77  <br><br>
    78  <gocode>
    79  
    80  func handleHomePage(w http.ResponseWriter, r *http.Request) {
    81      
    82  }
    83  
    84  </gocode>
    85  
    86  <h2>The End</h2>
    87  
    88  </body>
    89  </html>