• 2024-11-14Greenlight - Choosing a router
    We’regoingtousethepopularthird-partypackagehttprouterastherouterfor ourapplication,insteadofusinghttp.ServeMuxfromthestandard-library.Therearetworeasonsforthis:WewantourAPItoconsistentlysendJSONresponseswhereverpossib
  • 2024-11-14Greenlight - API versioning
    APIversioningAPIswhichsupportreal-worldbusinessesandusersoftenneedtochangetheirfunctionality andendpointsovertime—sometimesinabackwards-incompatibleway.So,toavoid problemsandconfusionforclients,it’sagoodideatoalwaysimp
  • 2024-11-14Greenlight - Directory Structure
     $mkdir-pbincmd/apiinternalmigrationsremote$touchMakefile$touchcmd/api/main.goAtthispointyourprojectdirectoryshouldlookexactlylikethis:greenlight├──bin├──cmd│└──api│└──main.go├──internal├─
  • 2024-11-14Greenlight - Endpoints and Actions
    MethodURLPatternActionGET/v1/healthcheckShowapplicationhealthandversioninformationGET/v1/moviesShowthedetailsofallmoviesPOST/v1/moviesCreateanewmovieGET/v1/movies/:idShowthedetailsofaspecificmoviePA