Skip to content

Instantly share code, notes, and snippets.

@Raffo
Created July 31, 2016 10:58
Show Gist options
  • Save Raffo/0bcc37995a15bd383944f099d94d1b82 to your computer and use it in GitHub Desktop.
Save Raffo/0bcc37995a15bd383944f099d94d1b82 to your computer and use it in GitHub Desktop.
go-swagger gist
func (p *ProjectResponse) projectsOKResponse(projects []*models.Project, ginCtx *gin.Context) {
ginCtx.JSON(http.StatusOK, projects)
}
func (p *ProjectResponse) projectOKResponse(project *models.Project, ginCtx *gin.Context) {
ginCtx.JSON(http.StatusOK, project)
}
func (p *ProjectResponse) projectCreateOKResponse(ginCtx *gin.Context) {
ginCtx.Status(http.StatusCreated)
}
func (p *ProjectResponse) badCreateProjectRequest(ginCtx *gin.Context, err error) {
e := &models.Error{Code: http.StatusBadRequest, Message: err.Error()}
ginCtx.JSON(http.StatusBadRequest, e)
}
func (p *ProjectResponse) internalError(ginCtx *gin.Context) {
e := &models.Error{Code: http.StatusInternalServerError, Message: "Internal server error"}
ginCtx.JSON(http.StatusInternalServerError, e)
}
func (p *ProjectResponse) projectNotFoundResponse(ginCtx *gin.Context) {
ginCtx.Status(http.StatusNotFound)
}
func (p *ProjectResponse) projectNoContentResponse(ginCtx *gin.Context) {
ginCtx.Status(http.StatusNoContent)
}
type ClusterResponse struct{}
func (c *ClusterResponse) clustersOKResponse(clusters []*models.Cluster, ginCtx *gin.Context) {
ginCtx.JSON(http.StatusOK, clusters)
}
func (p *ClusterResponse) clusterCreateOKResponse(ginCtx *gin.Context) {
ginCtx.Status(http.StatusCreated)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment