Skip to content

Commit

Permalink
feat: add cookie parameter to route method
Browse files Browse the repository at this point in the history
  • Loading branch information
pers0na2dev authored and EwenQuim committed Feb 21, 2024
1 parent 6dda095 commit 9e26c7d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/basic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func main() {
Message: "Hello, " + data.Name,
BestFramework: "Fuego!",
}, nil
}).WithDescription("Say hello to the world").AddHeader("test")
}).WithDescription("Say hello to the world").AddHeader("test").AddCookie("test")

// Standard net/http handler with automatic OpenAPI route declaration
fuego.GetStd(s, "/std", func(w http.ResponseWriter, r *http.Request) {
Expand Down
8 changes: 8 additions & 0 deletions mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ func (r Route[ResponseBody, RequestBody]) AddHeader(header string) Route[Respons
return r
}

func (r Route[ResponseBody, RequestBody]) AddCookie(cookie string) Route[ResponseBody, RequestBody] {
r.operation.Parameters = append(r.operation.Parameters, &openapi3.ParameterRef{
Value: openapi3.NewCookieParameter(cookie),
})

return r
}

func (r Route[ResponseBody, RequestBody]) AddTags(tags ...string) Route[ResponseBody, RequestBody] {
r.operation.Tags = append(r.operation.Tags, tags...)
return r
Expand Down

0 comments on commit 9e26c7d

Please sign in to comment.