Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GetFlag route #5

Merged
merged 1 commit into from
Oct 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pkg/handler/crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
type CRUD interface {
FindFlags(flag.FindFlagsParams) middleware.Responder
CreateFlag(flag.CreateFlagParams) middleware.Responder
GetFlag(flag.GetFlagParams) middleware.Responder
}

// NewCRUD creates a new CRUD instance
Expand Down Expand Up @@ -48,3 +49,15 @@ func (c *crud) CreateFlag(params flag.CreateFlagParams) middleware.Responder {
resp.SetPayload(e2r.MapFlag(f))
return resp
}

func (c *crud) GetFlag(params flag.GetFlagParams) middleware.Responder {
f := &entity.Flag{}
q := entity.NewFlagQuerySet(repo.GetDB())
err := q.IDEq(uint(params.FlagID)).One(f)
if err != nil {
return flag.NewGetFlagDefault(500)
}
resp := flag.NewGetFlagOK()
resp.SetPayload(e2r.MapFlag(f))
return resp
}
1 change: 1 addition & 0 deletions pkg/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func Setup(api *operations.FlagrAPI) {
c := NewCRUD()
api.FlagFindFlagsHandler = flag.FindFlagsHandlerFunc(c.FindFlags)
api.FlagCreateFlagHandler = flag.CreateFlagHandlerFunc(c.CreateFlag)
api.FlagGetFlagHandler = flag.GetFlagHandlerFunc(c.GetFlag)

e := NewEval()
api.EvaluationPostEvaluationHandler = evaluation.PostEvaluationHandlerFunc(e.PostEvaluation)
Expand Down
23 changes: 22 additions & 1 deletion swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,28 @@ paths:
description: generic error response
schema:
$ref: "#/definitions/error"

/flags/{flagID}:
get:
tags:
- flag
operationId: getFlag
parameters:
- in: path
name: flagID
description: numeric ID of the flag to get
required: true
type: integer
format: int32
minimum: 1
responses:
200:
description: returns the flag
schema:
$ref: "#/definitions/flag"
default:
description: generic error response
schema:
$ref: "#/definitions/error"
/evaluation:
post:
tags:
Expand Down
33 changes: 33 additions & 0 deletions swagger_gen/restapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions swagger_gen/restapi/operations/flag/get_flag.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 86 additions & 0 deletions swagger_gen/restapi/operations/flag/get_flag_parameters.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

115 changes: 115 additions & 0 deletions swagger_gen/restapi/operations/flag/get_flag_responses.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading