- 2024-11-15GoFurther - Chapter 5: Database Setup and Configuration
zzh@ZZHPC:/zdata/Github/greenlight$dockerpullpostgreszzh@ZZHPC:/zdata/Github/greenlight$dockerrun--namepostgres17-p5432:5432-ePOSTGRES_USER=root-ePOSTGRES_PASSWORD=root-dpostgres:latest zzh@ZZHPC:~$dockerexec-itpostgres17psql
- 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