46 lines
991 B
Go
46 lines
991 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// func JokeHandler(c *gin.Context) {
|
|
// c.Header("Content-Type", "application/json")
|
|
// c.JSON(http.StatusOK, jokes)
|
|
// }
|
|
|
|
func getUsersView(c *gin.Context) {
|
|
// dodanie nowej karty do bzy
|
|
fmt.Println("Dodanie do couchDB nowej karty pytania lub odowiedzi")
|
|
|
|
var userList []map[string]interface{}
|
|
|
|
allUsers := getAllUsers()
|
|
for _, arg := range allUsers {
|
|
tmp := make(map[string]interface{})
|
|
tmp["login"] = arg.login
|
|
tmp["userDescription"] = arg.userDescription
|
|
tmp["points"] = arg.points
|
|
userList = append(userList, tmp)
|
|
}
|
|
|
|
c.Header("Content-Type", "application/json")
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"code": http.StatusOK,
|
|
"allUsers": userList, // cast it to string before showing
|
|
})
|
|
}
|
|
|
|
func addNewUserView() {
|
|
// dodanie nowego użytkownika
|
|
fmt.Println("Rejestracja nowego użytkownika")
|
|
}
|
|
|
|
func loginUserView() {
|
|
//logowanie - czy jest w bazie
|
|
fmt.Println("Logowanie użytkownika")
|
|
}
|