handlers

package
v0.0.0-...-00c8e8d Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2018 License: MIT Imports: 13 Imported by: 1

Documentation

Overview

Package handlers contains the application logic (controllers).

All handlers expect JSON content (if any) and return JSON content, along with proper status codes. More information at: http://docs.crickapi.apiary.io/.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DetailProjectCreationFailed is the error message when inserting a project in database has failed.
	DetailProjectCreationFailed = "Project creation failed"
	// DetailFrameCreationFailed is the error message when inserting a frame in database has failed.
	DetailFrameCreationFailed = "Frame creation failed"
	// DetailFrameSelectionFailed is the error message when fetching frames from database has failed.
	DetailFrameSelectionFailed = "Frame selection failed"
	// DetailGetProjectFailed is the error message when the project to retrieve does not exist in database.
	DetailGetProjectFailed = "Unknown project"
	// DetailTeamSelectionFailed is the error when fetching a frame from database has failed.
	DetailTeamSelectionFailed = "Team selection failed"
	// DetailProjectNotFound is the error message when a project does not exist.
	DetailProjectNotFound = "Project not found"
)
View Source
var (
	// DefaultContentType is the default content type for handler responses.
	DefaultContentType = "application/json"

	// DetailInvalidRequest is the error message used when the request parsing has failed.
	DetailInvalidRequest = "Invalid request"
	// DetailMalformedJSON is the error message used when it is not possible to parse the JSON content.
	DetailMalformedJSON = "Malformed JSON"
	// DetailUserIsNotAllowedToPerformOperation is the error message when the user cannot perform an operation.
	DetailUserIsNotAllowedToPerformOperation = "Not allowed"
)
View Source
var (
	// DetailGetProjectsFailed is the error message used when fetching user's
	// projects from database has failed.
	DetailGetProjectsFailed = "Failed to retrieve projects"
	// DetailProjectWorkloadsRetrievalFailed is the error message used when
	// retrieving the project workloads from database has failed.
	DetailProjectWorkloadsRetrievalFailed = "Failed to retrieve project workloads"
)
View Source
var (
	// DetailGetTeamsFailed is the error message used when fetching teams from database has failed.
	DetailGetTeamsFailed = "Failed to retrieve teams"
	// DetailTeamCreationFailed is the error message used when inserting a team in database has failed.
	DetailTeamCreationFailed = "Team creation failed"
	// DetailGetTeamFailed is the error message used when retrieving a team from database has failed.
	DetailGetTeamFailed = "Failed to retrieve team"
	// DetailTeamUpdateFailed is the error message used when updating a team in database has failed.
	DetailTeamUpdateFailed = "Failed to update the team"
	// DetailTeamNotFound is the error message used when a team does not exist.
	DetailTeamNotFound = "Team not found"
	// DetailTeamDeletionFailed is the error message when deleting a team in database has failed.
	DetailTeamDeletionFailed = "Failed to delete the team"
	// DetailTeamAlreadyExists is the error message when the unique constraint
	// on (team name/owner_id) is violated
	DetailTeamAlreadyExists = "A team with this name already exists"
)
View Source
var (
	// DetailGetUsersByLoginFailed is the error message when retrieving users
	// by login in database has failed.
	DetailGetUsersByLoginFailed = "Failed to retrieve users by login"
)

Functions

This section is empty.

Types

type Handler

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

Handler is the structure that contains the different HTTP handlers.

func New

func New(repository models.Repository, logger *zap.Logger) Handler

New creates the main handler.

func (Handler) BulkInsertFrames

func (h Handler) BulkInsertFrames(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

BulkInsertFrames handles the bulk insertion of Watson frames.

func (Handler) CreateTeam

func (h Handler) CreateTeam(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

CreateTeam creates a new team and returns its id.

func (Handler) DeleteTeam

func (h Handler) DeleteTeam(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

DeleteTeam allows to delete an existing team.

func (Handler) GetFrames

func (h Handler) GetFrames(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

GetFrames returns the user's frames for the given project.

func (Handler) GetFramesSince

func (h Handler) GetFramesSince(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

GetFramesSince returns the user's frames, optionally since `last_sync` date.

func (Handler) GetProjectWorkloads

func (h Handler) GetProjectWorkloads(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

GetProjectWorkloads returns the workloads for a given project.

func (Handler) GetProjects

func (h Handler) GetProjects(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

GetProjects returns the user's projects.

func (Handler) GetTeams

func (h Handler) GetTeams(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

GetTeams returns the user's teams.

func (Handler) GetUsers

func (h Handler) GetUsers(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

GetUsers returns a list of users. It relies on a query string parameter q to autocomplete users.

func (Handler) SendError

func (h Handler) SendError(w http.ResponseWriter, statusCode int, detail string)

SendError returns a HTTP error in JSON.

func (Handler) UpdateTeam

func (h Handler) UpdateTeam(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

UpdateTeam allows to modify an existing team.

func (Handler) UsersGetMe

func (h Handler) UsersGetMe(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

UsersGetMe returns information related to the current logged user.

Jump to

Keyboard shortcuts

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