本文整理汇总了Golang中gitlab.com/kanban/kanban/modules/middleware.Context类的典型用法代码示例。如果您正苦于以下问题:Golang Context类的具体用法?Golang Context怎么用?Golang Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Context类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Configure
func Configure(ctx *middleware.Context, form models.BoardRequest) {
status, err := models.ConfigureBoard(ctx.User, ctx.Provider, &form)
if err != nil {
ctx.JSON(status, &models.ResponseError{
Success: false,
Message: err.Error(),
})
return
}
ctx.JSON(http.StatusOK, &models.Response{})
}
开发者ID:praveenscience,项目名称:kanban,代码行数:13,代码来源:board.go
示例2: CreateComment
// CreateComment creates new kanban comment
func CreateComment(ctx *middleware.Context, form models.CommentRequest) {
com, code, err := models.CreateComment(ctx.User, ctx.Provider, &form)
if err != nil {
ctx.JSON(code, &models.ResponseError{
Success: false,
Message: err.Error(),
})
return
}
ctx.JSON(http.StatusOK, &models.Response{
Data: com,
})
}
开发者ID:praveenscience,项目名称:kanban,代码行数:16,代码来源:comment.go
示例3: ListBoards
// ListBoards gets a list of board accessible by the authenticated user.
func ListBoards(ctx *middleware.Context) {
boards, err := models.ListBoards(ctx.User, ctx.Provider)
if err != nil {
ctx.JSON(http.StatusUnauthorized, &models.ResponseError{
Success: false,
Message: err.Error(),
})
return
}
ctx.JSON(http.StatusOK, &models.Response{
Data: boards,
})
}
开发者ID:praveenscience,项目名称:kanban,代码行数:16,代码来源:board.go
示例4: SignUp
// SignUp sing ups with data
func SignUp(ctx *middleware.Context, form auth.SignUp) {
u, err := models.UserSignUp(form.Uname, form.Email, form.Pass, form.Token, ctx.Provider)
if err != nil {
ctx.JSON(http.StatusBadRequest, models.ResponseError{
Success: false,
Message: err.Error(),
})
return
}
tokens, _ := u.SignedString()
ctx.JSON(http.StatusOK, auth.ResponseAuth{
Success: true,
Token: tokens,
})
}
开发者ID:praveenscience,项目名称:kanban,代码行数:19,代码来源:auth.go
示例5: MoveToCard
// MoveToCard updates an existing board card.
func MoveToCard(ctx *middleware.Context, form models.CardRequest) {
card, code, err := models.UpdateCard(ctx.User, ctx.Provider, &form)
if err != nil {
ctx.JSON(code, &models.ResponseError{
Success: false,
Message: err.Error(),
})
return
}
ctx.JSON(http.StatusOK, &models.Response{
Data: card,
})
ctx.Broadcast(card.RoutingKey(), &models.Response{
Data: card,
Event: "card.move",
})
source := models.ParseLabelToStage(form.Stage["source"])
dest := models.ParseLabelToStage(form.Stage["dest"])
com := models.CommentRequest{
CardId: form.CardId,
ProjectId: form.ProjectId,
Body: fmt.Sprintf("moved issue from **%s** to **%s**", source.Name, dest.Name),
}
go func() {
models.CreateComment(ctx.User, ctx.Provider, &com)
}()
}
开发者ID:praveenscience,项目名称:kanban,代码行数:34,代码来源:card.go
示例6: ListComments
// ListComments gets a list of comment on board and card
// accessible by the authenticated user.
func ListComments(ctx *middleware.Context) {
boards, err := models.ListComments(ctx.User, ctx.Provider, ctx.Query("project_id"), ctx.Query("issue_id"))
if err != nil {
ctx.JSON(http.StatusUnauthorized, &models.ResponseError{
Success: false,
Message: err.Error(),
})
return
}
ctx.JSON(http.StatusOK, &models.Response{
Data: boards,
})
}
开发者ID:praveenscience,项目名称:kanban,代码行数:17,代码来源:comment.go
示例7: ListMembers
// ListMembers gets a list of member on board accessible by the authenticated user.
func ListMembers(ctx *middleware.Context) {
members, err := models.ListMembers(ctx.User, ctx.Provider, ctx.Query("project_id"))
if err != nil {
ctx.JSON(http.StatusUnauthorized, &models.ResponseError{
Success: false,
Message: err.Error(),
})
return
}
ctx.JSON(http.StatusOK, members)
}
开发者ID:praveenscience,项目名称:kanban,代码行数:14,代码来源:user.go
示例8: ItemBoard
// ItemBoard gets a specific board, identified by project ID or
// NAMESPACE/BOARD_NAME, which is owned by the authenticated user.
func ItemBoard(ctx *middleware.Context) {
board, err := models.ItemBoard(ctx.User, ctx.Provider, ctx.Query("project_id"))
if err != nil {
if err, ok := err.(models.ReceivedDataErr); ok {
ctx.JSON(err.StatusCode, &models.ResponseError{
Success: false,
Message: err.Error(),
})
}
ctx.JSON(http.StatusInternalServerError, &models.ResponseError{
Success: false,
Message: err.Error(),
})
return
}
ctx.JSON(http.StatusOK, &models.Response{
Data: board,
})
}
开发者ID:colangiuli,项目名称:kanban,代码行数:23,代码来源:board.go
示例9: DeleteCard
// DeleteCard closed an existing board card.
func DeleteCard(ctx *middleware.Context, form models.CardRequest) {
card, code, err := models.DeleteCard(ctx.User, ctx.Provider, &form)
if err != nil {
ctx.JSON(code, &models.ResponseError{
Success: false,
Message: err.Error(),
})
return
}
ctx.JSON(http.StatusOK, &models.Response{
Data: card,
})
ctx.Broadcast(card.RoutingKey(), &models.Response{
Data: card,
Event: "card.delete",
})
}
开发者ID:praveenscience,项目名称:kanban,代码行数:21,代码来源:card.go
示例10: OauthLogin
// OauthLogin logins with gitlab and get access token
func OauthLogin(ctx *middleware.Context, form auth.Oauth2) {
tok, err := models.Exchange(form.Provider, form.Code)
if err != nil {
log.Printf("%s", err.Error())
ctx.JSON(http.StatusBadRequest, models.ResponseError{
Success: false,
Message: err.Error(),
})
return
}
user, err := models.UserOauthSignIn(form.Provider, tok)
if err != nil {
log.Printf("%s", err.Error())
ctx.JSON(http.StatusBadRequest, models.ResponseError{
Success: false,
Message: err.Error(),
})
return
}
user, err = models.LoadByToken(user, ctx.Provider)
if err != nil {
log.Printf("%s", err.Error())
ctx.JSON(http.StatusBadRequest, models.ResponseError{
Success: false,
Message: err.Error(),
})
return
}
user.Username = fmt.Sprintf("%s_%s", user.Username, ctx.Provider)
_, err = models.UpdateUser(user)
// todo add validation by oauth provider
if err != nil {
user, err = models.CreateUser(user)
}
if err != nil {
log.Printf("%s", err.Error())
ctx.JSON(http.StatusInternalServerError, models.ResponseError{
Success: false,
Message: err.Error(),
})
return
}
tokens, err := user.SignedString()
if err != nil {
log.Printf("%s", err.Error())
ctx.JSON(http.StatusBadRequest, models.ResponseError{
Success: false,
Message: err.Error(),
})
return
}
ctx.JSON(http.StatusOK, auth.ResponseAuth{
Success: true,
Token: tokens,
})
}
开发者ID:praveenscience,项目名称:kanban,代码行数:67,代码来源:auth.go
示例11: OauthUrl
// OauthUrl redirects to url for authorisation
func OauthUrl(ctx *middleware.Context) {
ctx.Redirect(models.AuthCodeURL(ctx.Query("provider")))
}
开发者ID:praveenscience,项目名称:kanban,代码行数:4,代码来源:auth.go
示例12: OauthHandler
// OauthHandler handles request from other services
func OauthHandler(ctx *middleware.Context) {
ctx.HTML(200, "templates/oauth")
}
开发者ID:praveenscience,项目名称:kanban,代码行数:4,代码来源:auth.go
注:本文中的gitlab.com/kanban/kanban/modules/middleware.Context类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论