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

merge the functionality of filter and search API in licenses. #16

Open
k-avy opened this issue Aug 28, 2023 · 1 comment
Open

merge the functionality of filter and search API in licenses. #16

k-avy opened this issue Aug 28, 2023 · 1 comment

Comments

@k-avy
Copy link
Collaborator

k-avy commented Aug 28, 2023

  • Create a single API to implement the application of filter and search in licenses:
    • Filter License API - api/licenses
    • Search in License API - api/licenses/search

The purpose is to create an API that can merge the results of filter and search API.

@dvjsharma
Copy link
Contributor

Hi @GMishx,

I have looked into this and agree that merging the filter and search functionalities makes sense. It seems unnecessary to have a separate search endpoint, especially when the search is intended specifically for licenses. Below are the two approaches via which this can be implemented-

  • In the initial approach, we can eliminate the /search endpoint entirely and incorporate search functionality within the FilterLicense handler for the /licenses endpoint. We will manage both GET and POST requests concurrently, and depending on the request method, we will direct the code flow to either the search functionality or the filter functionality.
  • Another approach involves redefining the search functionality. Currently, it requires a POST request, validates the request body with the model, and queries the database to provide results. Instead, this can be migrated to use query parameters. By doing so, we can integrate the search functionality into the FilterLicense endpoint without changing the request method. The code flow can then be determined by the presence of specific parameters, allowing redirection to either search or filter based on the client's input.

Use this as reference

LicenseDb/pkg/api/api.go

Lines 54 to 62 in a0f7261

licenses := unAuthorizedv1.Group("/licenses")
{
licenses.GET("", FilterLicense)
licenses.GET(":shortname", GetLicense)
}
search := unAuthorizedv1.Group("/search")
{
search.POST("", SearchInLicense)
}

Additionally, with this migration, the swagger documentation and tests in api_test.go will need to be updated.
If this issue is scheduled for development, I will create a PR. I require your input on the approach to use or any better suggestions.

Thanks!
CC @avinal @k-avy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants