only viewable if the client has a valid token
(res http.ResponseWriter, req *http.Request)
| 95 | |
| 96 | // only viewable if the client has a valid token |
| 97 | func protectedProfile(res http.ResponseWriter, req *http.Request) { |
| 98 | claims, ok := req.Context().Value(MyKey).(Claims) |
| 99 | if !ok { |
| 100 | res.Header().Set("Content-Type", "text/html") |
| 101 | fmt.Fprint(res, "Unauthorized - Please login <br>") |
| 102 | fmt.Fprintf(res, "<a href=\"login\"> Login </a>") |
| 103 | |
| 104 | return |
| 105 | } |
| 106 | res.Header().Set("Content-Type", "text/html") |
| 107 | fmt.Fprintf(res, "Hello %s <br>", claims.Username) |
| 108 | fmt.Fprintf(res, "<a href=\"logout\"> Logout </a>") |
| 109 | } |
| 110 | |
| 111 | // deletes the cookie |
| 112 | func logout(res http.ResponseWriter, req *http.Request) { |
nothing calls this directly
no outgoing calls
no test coverage detected