routes

package
v0.0.0-...-08d4403 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GithubClientID     string
	GithubClientSecret string
)

Github credentials

View Source
var (
	Router *mux.Router
)

Router main Gorilla mux router of app

Functions

func CreateSubscriptions

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

CreateSubscriptions godoc @Summary Create new subscription for the authenticated user @Description Create new subscription for the authenticated user @Tags subscription @Produce json @Security Github OAuth @Param subscriptions body models.Subscription true "Repository Name and list of Labels to create a new subscription" @Success 201 {string} Create Success @Failure 400 {string} Bad Request @Failure 401 {string} Unauthorized @Failure 500 {string} Internal Server Error @Router /api/v1/user/subscription/add [post]

func GetAllRepositories

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

GetAllRepositories godoc @Summary Get all repositories @Description Get complete repository information for all repositories from the database @Tags repository @Produce json @Success 200 {array} models.Repository @Failure 500 {string} Internal Server Error @Router /api/v1/repositories [get]

func GetAuthenticatedUser

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

GetAuthenticatedUser godoc @Summary Get user information from Github for authenticated user @Description Get user information from Github for authenticated user via session token @Tags user @Produce json @Security Github OAuth @Success 200 {object} UserInfo @Failure 401 {string} Unauthorized @Router /api/v1/user/authenticated [get]

func GetSubscribedLabelsByUserIDAndRepoName

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

GetSubscribedLabelsByUserIDAndRepoName godoc @Summary Get all subscriptions for the given `userID` and `repoName` of the authenticated user @Description Get all subscriptions for the given `userID` and `repoName` of the authenticated user @Tags subscription @Produce json @Security Github OAuth @Param repoName path string true "Repository Name for which subscription data needs to be fetched. Format `facebook/react`" @Success 200 {array} models.Labels @Failure 401 {string} Unauthorized @Failure 500 {string} Internal Server Error @Router /api/v1/user/{repoName}/subscription/labels [get]

func GetSubscriptionsByRepoID

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

GetSubscriptionsByRepoID godoc @Summary Get all subscriptions for the given `repoID` @Description Get all subscriptions for the given `repoID` @Tags subscription @Produce json @Param repoID path string true "Repository ID for which subscription data needs to be fetched" @Success 200 {array} models.UserIDLabel @Failure 500 {string} Internal Server Error @Router /api/v1/{repoID}/subscription/view [get]

func GetSubscriptionsByUserID

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

GetSubscriptionsByUserID godoc @Summary Get all subscriptions for the authenticated user @Description Get all subscriptions for the authenticated user @Tags subscription @Security Github OAuth @Produce json @Success 200 {array} models.Subscription @Failure 401 {string} Unauthorized @Failure 500 {string} Internal Server Error @Router /api/v1/user/subscription/view [get]

func GitHubLogin

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

GitHubLogin godoc @Summary Login via Github OAuth @Description Performs a Github OAuth by using the `code` provided in query param and then uses the received accessToken to fetch user information from Github. If it is a new user then user is also saved in the database. It also creates a user session for future authenticated calls. @Tags user @Produce json @Success 200 {object} UserInfo @Failure 401 {string} Unauthorized @Failure 500 {string} Internal Server Error @Router /api/v1/login/github/oauth2 [get]

func Init

func Init(githubClientID, githubClientSecret string)

Init initializes all types of routes

func Logout

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

Logout godoc @Summary Logout from user session @Description Performs the logout function by deleting user session @Tags user @Security Github OAuth @Success 200 {string} Success @Failure 500 {string} Internal Server Error @Router /api/v1/user/logout [get]

func RemoveSubscriptions

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

RemoveSubscriptions godoc @Summary Deletes existing subscription for the authenticated user @Description Deletes existing subscription for the authenticated user @Tags subscription @Produce json @Security Github OAuth @Param subscriptions body models.Subscription true "Repository Name and list of Labels which needs to be deleted from the existing subscription" @Success 204 {string} Remove Success @Failure 400 {string} Bad Request @Failure 401 {string} Unauthorized @Failure 500 {string} Internal Server Error @Router /api/v1/user/subscription/remove [delete]

func UpdateLastEventAtByRepoID

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

UpdateLastEventAtByRepoID godoc @Summary Updates `lastEventAt` time for the given `repoID` @Description Updates `lastEventAt` time for the given `repoID` in the database @Tags repository @Consume json @Produce json @Param repoID path string true "Repository ID for which `lastEventAt` needs to be updated" @Param lastEventAt body lastEventAt true "`lastEventAt` time (with timezone) at which last event for the repository occurred. Format `lastEventAt`: `2006-01-02 15:04:05-07:00`" @Success 204 {string} Updated LastEventAt Successfully "No Content" @Failure 400 {string} Bad Request @Failure 500 {string} Internal Server Error @Router /api/v1/repository/{repoID}/update/lastEventAt [put]

func UpdateSubscriptions

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

UpdateSubscriptions godoc @Summary Update existing subscription for the authenticated user @Description Update existing subscription for the authenticated user @Tags subscription @Produce json @Security Github OAuth @Param subscriptions body models.Subscription true "Repository Name and list of Labels which needs to be added to the existing subscription" @Success 204 {string} Update Success @Failure 400 {string} Bad Request @Failure 401 {string} Unauthorized @Failure 500 {string} Internal Server Error @Router /api/v1/user/subscription/update [put]

Types

type UserInfo

type UserInfo struct {
	Name        string `json:"name"`
	Username    string `json:"username"`
	Email       string `json:"email"`
	AvatarImg   string `json:"avatarImg"`
	AccessToken string `json:"accessToken"`
}

UserInfo struct to store user related information as received from Github. This is passed to UI for display

Jump to

Keyboard shortcuts

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