Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var UserLogin = func(w http.ResponseWriter, r *http.Request) { var login types.LoginRequest w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("X-Api-Correlation-Id", "1234") body, err := ioutil.ReadAll(r.Body) defer r.Body.Close() if err != nil { w.WriteHeader(http.StatusServiceUnavailable) return } err = json.Unmarshal(body, &login) if err != nil { w.WriteHeader(http.StatusServiceUnavailable) return } user, err := userRepository.ByUsername(login.Username) if err != nil { w.WriteHeader(http.StatusNotFound) } else if user.Username != login.Username || user.Password != login.Password { w.WriteHeader(http.StatusUnauthorized) } else { w.WriteHeader(http.StatusOK) res := types.LoginResponse{User: user} resBody, _ := json.Marshal(res) w.Write(resBody) } }
UserLogin is the login route.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.