api

package
v0.0.0-...-233ae75 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2016 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthId

func AuthId(token string) (int, error)

AuthId takes a token and returns the user ID encrypted. Now, this can't be faked because I have the secret signing key.

func AuthToken

func AuthToken(id int) (string, error)

AuthToken takes an ID and returns the token.

func DeleteComment

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

Delete

func DownVote

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

DownVote updates a vote and returns the voted comment

func Index

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

func Logger

func Logger(inner http.Handler, name string) http.Handler

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 NewRouter

func NewRouter() *mux.Router

func NewToken

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

NewToken

func Serve

func Serve(connection *sql.DB, port string)

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 ShowUser

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

ShowUser writes json of user

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)

func UserVotes

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

func Validate

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

Validate is middleware for making sure people can't delete the wrong shit

Types

type AuthAttempt

type AuthAttempt struct {
	Name     string `json:"username"`
	Password string `json:"password"`
}

type Claims

type Claims struct {
	UserId string `json:"user-id"`

	jwt.StandardClaims
}

type Local

type Local struct {
	LatMax float64 `json:"lat-max"`
	LatMin float64 `json:"lat-min"`
	LonMax float64 `json:"lon-max"`
	LonMin float64 `json:"lon-min"`
}

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
}

type Routes

type Routes []Route

Jump to

Keyboard shortcuts

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