Skip to content
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
2 changes: 1 addition & 1 deletion internal/dev_server/sdk/get_server_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func GetServerFlags(w http.ResponseWriter, r *http.Request) {
http.Error(w, "flag not found", http.StatusNotFound)
}
} else {
body = ServerAllPayloadFromFlagsState(allFlags)
body = ServerFlagsFromFlagsState(allFlags)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For PHP, the /sdk/flags endpoint should return only the flags in an array, not the full flags + segments payload.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait a sec. Will this break non-php sdks? I think we need this to have a 3rd case where we do just flags and not all?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this is a problem. This function only serves two routes -- /sdk/flags/{flagKey} and /sdk/flags.

These are routes that should exclusively be used by PHP SDKs. Non-PHP SDKs don't make flag only requests such as these.

I think we need this to have a 3rd case where we do just flags and not all?

Line 25 is serves all flags. Line 20 serves a single flag (assuming the flag key parameter is set).

The /all endpoint is serviced by the StreamServerAllPayload handler.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The /all endpoint is serviced by the StreamServerAllPayload handler.

Ahhh, OK. Cool. I forgot about that.

}
jsonBody, err := json.Marshal(body)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions internal/dev_server/sdk/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ func BindRoutes(router *mux.Router) {

router.Handle("/all", GetProjectKeyFromAuthorizationHeader(http.HandlerFunc(StreamServerAllPayload)))

router.PathPrefix("/sdk/flags/{flagKey}").
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GetServerFlags method already has a branch of logic that handles the individual flag request if the flagKey variable is set. However, we never defined that route so the variable would in fact get set.

Methods(http.MethodGet).
Handler(GetProjectKeyFromAuthorizationHeader(http.HandlerFunc(GetServerFlags)))
router.PathPrefix("/sdk/flags").
Methods(http.MethodGet).
Handler(GetProjectKeyFromAuthorizationHeader(http.HandlerFunc(GetServerFlags)))
Expand Down
Loading