handlers

package
v0.0.0-...-bdb8bbd Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func API

func API() (mux *chi.Mux)

API initializes all endpoints

func AcceptChallengeByID

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

AcceptChallengeByID accepts a challenge

func AuthHandler

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

AuthHandler Route to display Auth button

func CORS

func CORS(next http.Handler) http.Handler

CORS providing support for Cross-Origin Resource Sharing.

func CompleteChallengeByID

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

CompleteChallengeByID completes a challenge by challenge ID

func CreateChallenge

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

CreateChallenge creates a new challenge with post content

func CronComplete

func CronComplete()

CronComplete finds a list of expired challenges and processes them for completion

func DeclineChallengeByID

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

DeclineChallengeByID decline a challenge

func FileServer

func FileServer(r chi.Router, path string, root http.FileSystem)

FileServer conveniently sets up a http.FileServer handler to serve static files from a http.FileSystem.

func GetActiveChallengesByUserID

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

GetActiveChallengesByUserID gets all active challenges by user ID

func GetAllChallengesByUserID

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

GetAllChallengesByUserID gets all pending challenges by user ID

func GetAthleteByIDFromStrava

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

GetAthleteByIDFromStrava returns the strava athlete with the specified ID

func GetChallengeByID

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

GetChallengeByID returns challenge by ID from the database

func GetCompletedChallengesByUserID

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

GetCompletedChallengesByUserID gets all completed challenges by user ID

func GetEffortsBySegmentIDFromStravaWithUserID

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

GetEffortsBySegmentIDFromStravaWithUserID returns efforts by segment ID from Strava

func GetFriendsByUserID

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

GetFriendsByUserID returns a slice of user segments from the database

func GetFriendsByUserIDFromStrava

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

GetFriendsByUserIDFromStrava returns a list of friends for a specific user by ID from strava

func GetFriendsFromStrava

func GetFriendsFromStrava(numID int64) (friends []*models.Friend, err error)

GetFriendsFromStrava gets a users friends from Strava

func GetHealthCheck

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

GetHealthCheck returns response for health check

func GetPendingChallengesByUserID

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

GetPendingChallengesByUserID gets all pending challenges by user ID

func GetSegmentByID

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

GetSegmentByID returns segment by ID from the database

func GetSegmentByIDFromStrava

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

GetSegmentByIDFromStrava returns the strava segment with the specified ID

func GetSegmentByIDFromStravaWithUserID

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

GetSegmentByIDFromStravaWithUserID gets a segment by ID from strava using the users api key

func GetSegmentByIDWithUserID

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

GetSegmentByIDWithUserID gets a segment by ID from database using the users api key

func GetSegmentsByUserID

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

GetSegmentsByUserID returns a slice of user segments from the database

func GetSegmentsByUserIDFromStrava

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

GetSegmentsByUserIDFromStrava returns a list of segments for a specific user by ID from strava

func GetUserByID

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

GetUserByID returns user by ID from the database

func GetUserSegmentsFromStrava

func GetUserSegmentsFromStrava(numID int64, page int) (userSegmentSlice []*models.UserSegment, err error)

GetUserSegmentsFromStrava gets a users recently completed segments from Strava

func UpdateAllUsersFromStrava

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

UpdateAllUsersFromStrava returns all updated users from Strava

func UpdateAthleteFromStrava

func UpdateAthleteFromStrava(numID int64) (*models.User, error)

UpdateAthleteFromStrava updates athlete information from Strava

func UpdateChallengeEffort

func UpdateChallengeEffort(ID bson.ObjectId, UserID int64) (*models.Challenge, error)

UpdateChallengeEffort grabs challenge effort information for a user from Strava

func UpdateChallengeResult

func UpdateChallengeResult(id bson.ObjectId) error

UpdateChallengeResult determines the result of the challenge

Types

type ContextResponseWriter

type ContextResponseWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

ContextResponseWriter implements the ResponseWriter interface for the context package

func (*ContextResponseWriter) WriteHeader

func (crw *ContextResponseWriter) WriteHeader(code int)

WriteHeader sets the header for the ResponseWriter interface in the context package

type Response

type Response struct {
	// contains filtered or unexported fields
}

Response for all JSON requests

func New

New instantiates a new Response struct and attaches the Gin context. It returns the Response struct.

func (*Response) Render

func (r *Response) Render(code int, content interface{})

Render encodes the status and content to the Response struct

Jump to

Keyboard shortcuts

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