How to properly call my api and how to store and manage my data?
hey guys, i wanted to ask you for some advice. so im developing an api for learning purposes. so the api has to return a json with things that i should take on a hike. the idea is to call an endpoint, provide a distance and a season of the year, and then my api would return a list of items. ive just started and i already have some questions:
- would it be better to provide my input using path variables (localhost:8080/api/v1/100/winter) or using query parameters(localhost:8080/api/v1/?distance=100&season=winter)?
- currently i have just a simple controller, that returns "Hello world", but now i want to add a service which will hold all the logic. I have service interface and the implementation. Obviously, I will be injecting the interface, but the question is how? I can inject it through the constructor, through the setter, or through the class field. Which method is better?
- How would you advise me to order/store the items needed for the hike (knife, hatchet, water, etc)? Im not sure I need to have a database, becaus this application is very primitive and there would be nothing to store. So i was thinking about using enums. I would have smth like BaseItems enum which would have the items that are always needed in every season (water, socks, food) and then I would have 4 more enums (SummerItems, WinterItems, etc) that would extend/inherit base items from the BaseItems enum, and would store additional items (tea, hat, woolen socks for winter, rainwear for autumn and summer, etc). Would it make sense?