Documentation ¶
Index ¶
- func AuthId(token string) (int, error)
- func AuthToken(id int) (string, error)
- func DeleteComment(w http.ResponseWriter, r *http.Request)
- func DownVote(w http.ResponseWriter, r *http.Request)
- func Index(w http.ResponseWriter, r *http.Request)
- func Logger(inner http.Handler, name string) http.Handler
- func Login(w http.ResponseWriter, r *http.Request)
- func Logout(w http.ResponseWriter, r *http.Request)
- func NewComment(w http.ResponseWriter, r *http.Request)
- func NewRouter() *mux.Router
- func NewToken(w http.ResponseWriter, r *http.Request)
- func Serve(connection *sql.DB, port string)
- func ShowComment(w http.ResponseWriter, r *http.Request)
- func ShowComments(w http.ResponseWriter, r *http.Request)
- func ShowLocalComments(w http.ResponseWriter, r *http.Request)
- func ShowUser(w http.ResponseWriter, r *http.Request)
- func ShowUsers(w http.ResponseWriter, r *http.Request)
- func Signup(w http.ResponseWriter, r *http.Request)
- func UpVote(w http.ResponseWriter, r *http.Request)
- func UserComments(w http.ResponseWriter, r *http.Request)
- func UserVotes(w http.ResponseWriter, r *http.Request)
- func Validate(w http.ResponseWriter, r *http.Request)
- type AuthAttempt
- type Claims
- type Local
- type Route
- type Routes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthId ¶
AuthId takes a token and returns the user ID encrypted. Now, this can't be faked because I have the secret signing key.
func DownVote ¶
func DownVote(w http.ResponseWriter, r *http.Request)
DownVote updates a vote and returns the voted comment
func Login ¶
func Login(w http.ResponseWriter, r *http.Request)
Login authenticates user and returns the token this token must be included in the Header Authentication: field for Posting and Voting.
func Logout ¶
func Logout(w http.ResponseWriter, r *http.Request)
Logout deletes the cookie. There is no cookie. So this doesn't make any sense.
func NewComment ¶
func NewComment(w http.ResponseWriter, r *http.Request)
DB Write
NewComment Writes a new comment to db If no user is specified, use 0 for id
func ShowComment ¶
func ShowComment(w http.ResponseWriter, r *http.Request)
ShowComment returns a json of a comment with the id. This comment will have the User in the User field.
func ShowComments ¶
func ShowComments(w http.ResponseWriter, r *http.Request)
ShowComments encodes json of ALLL comments
func ShowLocalComments ¶
func ShowLocalComments(w http.ResponseWriter, r *http.Request)
ShowLocalComments A post for finding the comments by local TODO: Add users to comments
func ShowUsers ¶
func ShowUsers(w http.ResponseWriter, r *http.Request)
############################################################ Users
############################################################ ShowUsers collects all users TODO: New User ShowUsers return a list of all users
func Signup ¶
func Signup(w http.ResponseWriter, r *http.Request)
Signup adds a new user to the database.
func UpVote ¶
func UpVote(w http.ResponseWriter, r *http.Request)
Update DB, Upvote and Downvote
UpVote updates a comment and returns the voted comment
func UserComments ¶
func UserComments(w http.ResponseWriter, r *http.Request)
Types ¶
type AuthAttempt ¶
type Claims ¶
type Claims struct { UserId string `json:"user-id"` jwt.StandardClaims }