users

package
v0.0.0-...-0120b79 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 20, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package users creates or fetchs user data from Cassandra

Package users creates or fetchs user data from Cassandra

Package users creates or fetchs user data from Cassandra

Package users creates or fetchs user data from Cassandra

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enrich

func Enrich(uuids []gocql.UUID) map[string]string

Enrich -- turns an array of user UUIDs into a map of {uuid: "firstname lastname"} params: uuids - array of user UUIDs to fetch returns: a map[string]string of {uuid: "firstname lastname"}

func Get

func Get(w http.ResponseWriter, r *http.Request)

Get -- handles GET request to /users/ to fetch all users params: w - response writer for building JSON payload response r - request reader to fetch form data or url params (unused here)

func GetOne

func GetOne(w http.ResponseWriter, r *http.Request)

GetOne -- handles GET request to /users/{user_uuid} to fetch one user params: w - response writer for building JSON payload response r - request reader to fetch form data or url params

func Post

func Post(w http.ResponseWriter, r *http.Request)

Post -- handles POST request to /users/new to create new user params: w - response writer for building JSON payload response r - request reader to fetch form data or url params

Types

type AllUsersResponse

type AllUsersResponse struct {
	Users []User `json:"users"`
}

AllUsersResponse to form payload of an array of User structs

type ErrorResponse

type ErrorResponse struct {
	Errors []string `json:"errors"`
}

ErrorResponse returns an array of error strings if appropriate

type GetUserResponse

type GetUserResponse struct {
	User User `json:"user"`
}

GetUserResponse to form payload returning a single User struct

type NewUserResponse

type NewUserResponse struct {
	ID gocql.UUID `json:"id"`
}

NewUserResponse builds a payload of new user resource ID

type User

type User struct {
	ID        gocql.UUID `json:"id"`
	FirstName string     `json:"firstName"`
	LastName  string     `json:"lastName"`
	Email     string     `json:"email"`
	Age       int        `json:"age"`
	City      string     `json:"city"`
}

User struct to hold profile data for our user

func FormToUser

func FormToUser(r *http.Request) (User, []string)

FormToUser -- fills a User struct with submitted form data params: r - request reader to fetch form data or url params (unused here) returns: User struct if successful array of strings of errors if any occur during processing

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL