[{"data":1,"prerenderedAt":1103},["ShallowReactive",2],{"navigation_docs":3,"-projects-file-backed-api":377,"-projects-file-backed-api-surround":1098},[4,39,114,144,184,244,293,362],{"title":5,"icon":6,"path":7,"stem":8,"children":9,"page":6},"Getting Started",false,"\u002Fgetting-started","1.getting-started",[10,15,20,25,30,35],{"title":11,"path":12,"stem":13,"icon":14},"Learning Path","\u002Fgetting-started\u002Flearning-path","1.getting-started\u002F1.learning-path","i-lucide-map",{"title":16,"path":17,"stem":18,"icon":19},"Introduction","\u002Fgetting-started\u002Fintroduction","1.getting-started\u002F2.introduction","i-lucide-house",{"title":21,"path":22,"stem":23,"icon":24},"Installation","\u002Fgetting-started\u002Finstallation","1.getting-started\u002F3.installation","i-lucide-download",{"title":26,"path":27,"stem":28,"icon":29},"Your First Program","\u002Fgetting-started\u002Ffirst-program","1.getting-started\u002F4.first-program","i-lucide-play",{"title":31,"path":32,"stem":33,"icon":34},"Modules and Dependencies","\u002Fgetting-started\u002Fmodules-and-dependencies","1.getting-started\u002F5.modules-and-dependencies","i-lucide-package-open",{"title":36,"path":37,"stem":38,"icon":34},"Advanced Modules","\u002Fgetting-started\u002Fadvanced-modules","1.getting-started\u002F6.advanced-modules",{"title":40,"path":41,"stem":42,"children":43,"page":6},"Fundamentals","\u002Ffundamentals","2.fundamentals",[44,49,54,59,64,69,74,79,84,89,94,99,104,109],{"title":45,"path":46,"stem":47,"icon":48},"Program Structure","\u002Ffundamentals\u002Fprogram-structure","2.fundamentals\u002F1.program-structure","i-lucide-workflow",{"title":50,"path":51,"stem":52,"icon":53},"Structs and Methods","\u002Ffundamentals\u002Fstructs-and-methods","2.fundamentals\u002F10.structs-and-methods","i-lucide-box",{"title":55,"path":56,"stem":57,"icon":58},"Interfaces","\u002Ffundamentals\u002Finterfaces","2.fundamentals\u002F11.interfaces","i-lucide-plug",{"title":60,"path":61,"stem":62,"icon":63},"Error Handling","\u002Ffundamentals\u002Ferrors","2.fundamentals\u002F12.errors","i-lucide-triangle-alert",{"title":65,"path":66,"stem":67,"icon":68},"Defined Types and Type Aliases","\u002Ffundamentals\u002Fdefined-types","2.fundamentals\u002F13.defined-types","i-lucide-tags",{"title":70,"path":71,"stem":72,"icon":73},"Generics","\u002Ffundamentals\u002Fgenerics","2.fundamentals\u002F14.generics","i-lucide-blocks",{"title":75,"path":76,"stem":77,"icon":78},"Project Structure","\u002Ffundamentals\u002Fproject-structure","2.fundamentals\u002F2.project-structure","i-lucide-folder-tree",{"title":80,"path":81,"stem":82,"icon":83},"Project Layout","\u002Ffundamentals\u002Fproject-layout","2.fundamentals\u002F3.project-layout","i-lucide-layout",{"title":85,"path":86,"stem":87,"icon":88},"Variables and Data Types","\u002Ffundamentals\u002Fvariables-and-types","2.fundamentals\u002F4.variables-and-types","i-lucide-variable",{"title":90,"path":91,"stem":92,"icon":93},"Functions","\u002Ffundamentals\u002Ffunctions","2.fundamentals\u002F5.functions","i-lucide-braces",{"title":95,"path":96,"stem":97,"icon":98},"Control Statements","\u002Ffundamentals\u002Fcontrol-statements","2.fundamentals\u002F6.control-statements","i-lucide-git-branch",{"title":100,"path":101,"stem":102,"icon":103},"Pointers","\u002Ffundamentals\u002Fpointers","2.fundamentals\u002F7.pointers","i-lucide-mouse-pointer-2",{"title":105,"path":106,"stem":107,"icon":108},"Arrays and Slices","\u002Ffundamentals\u002Farrays-and-slices","2.fundamentals\u002F8.arrays-and-slices","i-lucide-list",{"title":110,"path":111,"stem":112,"icon":113},"Maps","\u002Ffundamentals\u002Fmaps","2.fundamentals\u002F9.maps","i-lucide-table-properties",{"title":115,"path":116,"stem":117,"children":118,"page":6},"Concurrency","\u002Fconcurrency","3.concurrency",[119,124,129,134,139],{"title":120,"path":121,"stem":122,"icon":123},"Concurrency Model","\u002Fconcurrency\u002Fconcurrency-model","3.concurrency\u002F1.concurrency-model","i-lucide-network",{"title":125,"path":126,"stem":127,"icon":128},"Goroutines","\u002Fconcurrency\u002Fgoroutines","3.concurrency\u002F2.goroutines","i-lucide-git-fork",{"title":130,"path":131,"stem":132,"icon":133},"Channels","\u002Fconcurrency\u002Fchannels","3.concurrency\u002F3.channels","i-lucide-arrow-left-right",{"title":135,"path":136,"stem":137,"icon":138},"Select and Cancellation","\u002Fconcurrency\u002Fselect-and-cancellation","3.concurrency\u002F4.select-and-cancellation","i-lucide-circle-stop",{"title":140,"path":141,"stem":142,"icon":143},"Synchronization","\u002Fconcurrency\u002Fsynchronization","3.concurrency\u002F5.synchronization","i-lucide-lock-keyhole",{"title":145,"path":146,"stem":147,"children":148,"page":6},"Standard Library","\u002Fstandard-library","4.standard-library",[149,154,159,164,169,174,179],{"title":150,"path":151,"stem":152,"icon":153},"Standard Library Overview","\u002Fstandard-library\u002Foverview","4.standard-library\u002F1.overview","i-lucide-library",{"title":155,"path":156,"stem":157,"icon":158},"Text and Formatting","\u002Fstandard-library\u002Ftext-and-formatting","4.standard-library\u002F2.text-and-formatting","i-lucide-text",{"title":160,"path":161,"stem":162,"icon":163},"Files and JSON","\u002Fstandard-library\u002Ffiles-and-json","4.standard-library\u002F3.files-and-json","i-lucide-file-json",{"title":165,"path":166,"stem":167,"icon":168},"HTTP Clients and Servers","\u002Fstandard-library\u002Fhttp","4.standard-library\u002F4.http","i-lucide-server",{"title":170,"path":171,"stem":172,"icon":173},"Testing","\u002Fstandard-library\u002Ftesting","4.standard-library\u002F5.testing","i-lucide-flask-conical",{"title":175,"path":176,"stem":177,"icon":178},"Command-Line Tools and Configuration","\u002Fstandard-library\u002Fcommand-line-and-configuration","4.standard-library\u002F6.command-line-and-configuration","i-lucide-terminal-square",{"title":180,"path":181,"stem":182,"icon":183},"Structured Logging","\u002Fstandard-library\u002Fstructured-logging","4.standard-library\u002F7.structured-logging","i-lucide-scroll-text",{"title":185,"path":186,"stem":187,"children":188,"page":6},"Backend Development","\u002Fbackend-development","5.backend-development",[189,194,199,204,209,214,219,224,229,234,239],{"title":190,"path":191,"stem":192,"icon":193},"Backend Roadmap","\u002Fbackend-development\u002Fbackend-roadmap","5.backend-development\u002F1.backend-roadmap","i-lucide-route",{"title":195,"path":196,"stem":197,"icon":198},"Graceful Shutdown","\u002Fbackend-development\u002Fgraceful-shutdown","5.backend-development\u002F10.graceful-shutdown","i-lucide-power",{"title":200,"path":201,"stem":202,"icon":203},"Production Checklist","\u002Fbackend-development\u002Fproduction-checklist","5.backend-development\u002F11.production-checklist","i-lucide-clipboard-check",{"title":205,"path":206,"stem":207,"icon":208},"HTTP API Design","\u002Fbackend-development\u002Fhttp-api-design","5.backend-development\u002F2.http-api-design","i-lucide-waypoints",{"title":210,"path":211,"stem":212,"icon":213},"Middleware","\u002Fbackend-development\u002Fmiddleware","5.backend-development\u002F3.middleware","i-lucide-layers-3",{"title":215,"path":216,"stem":217,"icon":218},"Validation","\u002Fbackend-development\u002Fvalidation","5.backend-development\u002F4.validation","i-lucide-list-checks",{"title":220,"path":221,"stem":222,"icon":223},"Application Wiring","\u002Fbackend-development\u002Fapplication-wiring","5.backend-development\u002F5.application-wiring","i-lucide-cable",{"title":225,"path":226,"stem":227,"icon":228},"Observability","\u002Fbackend-development\u002Fobservability","5.backend-development\u002F6.observability","i-lucide-activity",{"title":230,"path":231,"stem":232,"icon":233},"Database SQL","\u002Fbackend-development\u002Fdatabase-sql","5.backend-development\u002F7.database-sql","i-lucide-database",{"title":235,"path":236,"stem":237,"icon":238},"Transactions","\u002Fbackend-development\u002Ftransactions","5.backend-development\u002F8.transactions","i-lucide-repeat-2",{"title":240,"path":241,"stem":242,"icon":243},"Authentication and Authorization","\u002Fbackend-development\u002Fauthentication","5.backend-development\u002F9.authentication","i-lucide-shield-check",{"title":245,"path":246,"stem":247,"children":248,"page":6},"Advanced Go","\u002Fadvanced-go","6.advanced-go",[249,254,259,264,269,274,278,283,288],{"title":250,"path":251,"stem":252,"icon":253},"Advanced Go Roadmap","\u002Fadvanced-go\u002Fadvanced-roadmap","6.advanced-go\u002F1.advanced-roadmap","i-lucide-brain-circuit",{"title":255,"path":256,"stem":257,"icon":258},"Reflection","\u002Fadvanced-go\u002Freflection","6.advanced-go\u002F2.reflection","i-lucide-scan-search",{"title":260,"path":261,"stem":262,"icon":263},"Memory and Garbage Collection","\u002Fadvanced-go\u002Fmemory-and-garbage-collection","6.advanced-go\u002F3.memory-and-garbage-collection","i-lucide-memory-stick",{"title":265,"path":266,"stem":267,"icon":268},"Benchmarking and Profiling","\u002Fadvanced-go\u002Fbenchmarking-and-profiling","6.advanced-go\u002F4.benchmarking-and-profiling","i-lucide-gauge",{"title":270,"path":271,"stem":272,"icon":273},"Advanced Testing and Fuzzing","\u002Fadvanced-go\u002Fadvanced-testing-and-fuzzing","6.advanced-go\u002F5.advanced-testing-and-fuzzing","i-lucide-microscope",{"title":275,"path":276,"stem":277,"icon":48},"Advanced Concurrency","\u002Fadvanced-go\u002Fadvanced-concurrency","6.advanced-go\u002F6.advanced-concurrency",{"title":279,"path":280,"stem":281,"icon":282},"Unsafe and C Boundaries","\u002Fadvanced-go\u002Funsafe-and-cgo","6.advanced-go\u002F7.unsafe-and-cgo","i-lucide-radiation",{"title":284,"path":285,"stem":286,"icon":287},"Package and API Design","\u002Fadvanced-go\u002Fpackage-and-api-design","6.advanced-go\u002F8.package-and-api-design","i-lucide-boxes",{"title":289,"path":290,"stem":291,"icon":292},"Distributed Reliability","\u002Fadvanced-go\u002Fdistributed-reliability","6.advanced-go\u002F9.distributed-reliability","i-lucide-cloud-cog",{"title":294,"path":295,"stem":296,"children":297,"page":6},"Projects","\u002Fprojects","7.projects",[298,316,332,347],{"title":299,"path":300,"stem":301,"children":302,"icon":305},"CLI Task Manager","\u002Fprojects\u002Fcli-task-manager","7.projects\u002F1.cli-task-manager\u002Findex",[303,306,311],{"title":304,"path":300,"stem":301,"icon":305},"Project — CLI Task Manager","i-lucide-list-todo",{"title":307,"path":308,"stem":309,"icon":310},"CLI — Domain and Storage","\u002Fprojects\u002Fcli-task-manager\u002Fdomain-and-storage","7.projects\u002F1.cli-task-manager\u002F1.domain-and-storage","i-lucide-save",{"title":312,"path":313,"stem":314,"icon":315},"CLI — Commands and Tests","\u002Fprojects\u002Fcli-task-manager\u002Fcommands-and-tests","7.projects\u002F1.cli-task-manager\u002F2.commands-and-tests","i-lucide-terminal",{"title":317,"path":318,"stem":319,"children":320,"icon":323},"Concurrent URL Checker","\u002Fprojects\u002Fconcurrent-url-checker","7.projects\u002F2.concurrent-url-checker\u002Findex",[321,324,328],{"title":322,"path":318,"stem":319,"icon":323},"Project — Concurrent URL Checker","i-lucide-radar",{"title":325,"path":326,"stem":327,"icon":128},"URL Checker — Worker Pipeline","\u002Fprojects\u002Fconcurrent-url-checker\u002Fworker-pipeline","7.projects\u002F2.concurrent-url-checker\u002F1.worker-pipeline",{"title":329,"path":330,"stem":331,"icon":173},"URL Checker — Cancellation and Tests","\u002Fprojects\u002Fconcurrent-url-checker\u002Fcancellation-and-tests","7.projects\u002F2.concurrent-url-checker\u002F2.cancellation-and-tests",{"title":333,"path":334,"stem":335,"children":336},"File-backed API","\u002Fprojects\u002Ffile-backed-api","7.projects\u002F3.file-backed-api\u002Findex",[337,339,343],{"title":338,"path":334,"stem":335},"File-backed notes API",{"title":340,"path":341,"stem":342},"File store and concurrency","\u002Fprojects\u002Ffile-backed-api\u002Ffile-store-and-concurrency","7.projects\u002F3.file-backed-api\u002F1.file-store-and-concurrency",{"title":344,"path":345,"stem":346},"HTTP layer and tests","\u002Fprojects\u002Ffile-backed-api\u002Fhttp-and-tests","7.projects\u002F3.file-backed-api\u002F2.http-and-tests",{"title":348,"path":349,"stem":350,"children":351},"Production REST API","\u002Fprojects\u002Fproduction-rest-api","7.projects\u002F4.production-rest-api\u002Findex",[352,354,358],{"title":353,"path":349,"stem":350},"Production REST API capstone",{"title":355,"path":356,"stem":357},"Persistence and authentication","\u002Fprojects\u002Fproduction-rest-api\u002Fpersistence-and-auth","7.projects\u002F4.production-rest-api\u002F1.persistence-and-auth",{"title":359,"path":360,"stem":361},"Operations and release","\u002Fprojects\u002Fproduction-rest-api\u002Foperations-and-release","7.projects\u002F4.production-rest-api\u002F2.operations-and-release",{"title":363,"path":364,"stem":365,"children":366,"page":6},"Meta","\u002Fmeta","99.meta",[367,372],{"title":368,"path":369,"stem":370,"icon":371},"About","\u002Fmeta\u002Fabout","99.meta\u002F1.about","i-lucide-info",{"title":373,"path":374,"stem":375,"icon":376},"Acknowledgements","\u002Fmeta\u002Facknowledgements","99.meta\u002F2.acknowledgements","i-lucide-heart-handshake",{"id":378,"title":338,"body":379,"description":1092,"extension":1093,"links":1094,"meta":1095,"navigation":572,"path":334,"seo":1096,"stem":335,"__hash__":1097},"docs\u002F7.projects\u002F3.file-backed-api\u002Findex.md",{"type":380,"value":381,"toc":1083},"minimark",[382,389,393,397,402,421,425,428,534,541,545,940,951,955,963,974,978,981,1012,1019,1023,1032,1054,1058,1072,1075,1079],[383,384],"learning-lesson-meta",{"description":385,"difficulty":386,"prerequisites":387,"time":388},"Plan a small notes API before implementing its storage and transport layers.","Intermediate","HTTP handlers, JSON, files, structs, interfaces, and mutexes","50 minutes",[390,391,338],"h1",{"id":392},"file-backed-notes-api",[394,395,396],"p",{},"This project combines the language, standard-library, and API lessons into one service. It deliberately stores data in a JSON file instead of a database. That keeps the persistence rules visible while you practise boundaries that will still matter when a database is introduced.",[398,399,401],"h2",{"id":400},"what-you-will-learn","What you will learn",[403,404,405,409,412,415,418],"ul",{},[406,407,408],"li",{},"turn product requirements into a small domain model;",[406,410,411],{},"separate HTTP, business, and storage responsibilities;",[406,413,414],{},"define errors that do not leak implementation details;",[406,416,417],{},"plan safe file updates and concurrent access;",[406,419,420],{},"identify when a file store is no longer appropriate.",[398,422,424],{"id":423},"requirements","Requirements",[394,426,427],{},"The API must support:",[429,430,431,447],"table",{},[432,433,434],"thead",{},[435,436,437,441,444],"tr",{},[438,439,440],"th",{},"Method",[438,442,443],{},"Path",[438,445,446],{},"Result",[448,449,450,470,484,501,517],"tbody",{},[435,451,452,459,464],{},[453,454,455],"td",{},[456,457,458],"code",{},"POST",[453,460,461],{},[456,462,463],{},"\u002Fnotes",[453,465,466,467],{},"Create a note and return ",[456,468,469],{},"201 Created",[435,471,472,477,481],{},[453,473,474],{},[456,475,476],{},"GET",[453,478,479],{},[456,480,463],{},[453,482,483],{},"Return all notes",[435,485,486,490,495],{},[453,487,488],{},[456,489,476],{},[453,491,492],{},[456,493,494],{},"\u002Fnotes\u002F{id}",[453,496,497,498],{},"Return one note or ",[456,499,500],{},"404 Not Found",[435,502,503,508,512],{},[453,504,505],{},[456,506,507],{},"PUT",[453,509,510],{},[456,511,494],{},[453,513,514,515],{},"Replace a note or return ",[456,516,500],{},[435,518,519,524,528],{},[453,520,521],{},[456,522,523],{},"DELETE",[453,525,526],{},[456,527,494],{},[453,529,530,531],{},"Delete a note and return ",[456,532,533],{},"204 No Content",[394,535,536,537,540],{},"Reject malformed JSON and blank titles with ",[456,538,539],{},"400 Bad Request",". Limit request bodies so one client cannot make the process consume unbounded memory.",[398,542,544],{"id":543},"start-with-the-domain","Start with the domain",[546,547,552],"pre",{"className":548,"code":549,"language":550,"meta":551,"style":551},"language-go shiki shiki-themes solarized-light material-theme one-dark-pro","package note\n\nimport (\n    \"context\"\n    \"errors\"\n    \"time\"\n)\n\nvar ErrNotFound = errors.New(\"note not found\")\n\ntype Note struct {\n    ID        string    `json:\"id\"`\n    Title     string    `json:\"title\"`\n    Body      string    `json:\"body\"`\n    CreatedAt time.Time `json:\"createdAt\"`\n    UpdatedAt time.Time `json:\"updatedAt\"`\n}\n\ntype Store interface {\n    List(context.Context) ([]Note, error)\n    Get(context.Context, string) (Note, error)\n    Create(context.Context, Note) error\n    Replace(context.Context, Note) error\n    Delete(context.Context, string) error\n}\n","go","",[456,553,554,567,574,585,599,609,619,625,630,668,673,688,707,723,739,761,780,786,791,804,836,868,891,913,935],{"__ignoreMap":551},[555,556,559,563],"span",{"class":557,"line":558},"line",1,[555,560,562],{"class":561},"sEOdo","package",[555,564,566],{"class":565},"snwKR"," note\n",[555,568,570],{"class":557,"line":569},2,[555,571,573],{"emptyLinePlaceholder":572},true,"\n",[555,575,577,581],{"class":557,"line":576},3,[555,578,580],{"class":579},"s7Bcg","import",[555,582,584],{"class":583},"shFME"," (\n",[555,586,588,592,596],{"class":557,"line":587},4,[555,589,591],{"class":590},"sED5a","    \"",[555,593,595],{"class":594},"sdLNw","context",[555,597,598],{"class":590},"\"\n",[555,600,602,604,607],{"class":557,"line":601},5,[555,603,591],{"class":590},[555,605,606],{"class":594},"errors",[555,608,598],{"class":590},[555,610,612,614,617],{"class":557,"line":611},6,[555,613,591],{"class":590},[555,615,616],{"class":594},"time",[555,618,598],{"class":590},[555,620,622],{"class":557,"line":621},7,[555,623,624],{"class":583},")\n",[555,626,628],{"class":557,"line":627},8,[555,629,573],{"emptyLinePlaceholder":572},[555,631,633,636,640,644,647,650,654,657,660,664,666],{"class":557,"line":632},9,[555,634,635],{"class":561},"var",[555,637,639],{"class":638},"s45-6"," ErrNotFound",[555,641,643],{"class":642},"su2KV"," =",[555,645,646],{"class":638}," errors",[555,648,649],{"class":583},".",[555,651,653],{"class":652},"sisdC","New",[555,655,656],{"class":583},"(",[555,658,659],{"class":590},"\"",[555,661,663],{"class":662},"sVazx","note not found",[555,665,659],{"class":590},[555,667,624],{"class":583},[555,669,671],{"class":557,"line":670},10,[555,672,573],{"emptyLinePlaceholder":572},[555,674,676,679,682,685],{"class":557,"line":675},11,[555,677,678],{"class":561},"type",[555,680,681],{"class":565}," Note",[555,683,684],{"class":561}," struct",[555,686,687],{"class":583}," {\n",[555,689,691,694,698,701,704],{"class":557,"line":690},12,[555,692,693],{"class":638},"    ID",[555,695,697],{"class":696},"sF6sA","        string",[555,699,700],{"class":590},"    `",[555,702,703],{"class":662},"json:\"id\"",[555,705,706],{"class":590},"`\n",[555,708,710,713,716,718,721],{"class":557,"line":709},13,[555,711,712],{"class":638},"    Title",[555,714,715],{"class":696},"     string",[555,717,700],{"class":590},[555,719,720],{"class":662},"json:\"title\"",[555,722,706],{"class":590},[555,724,726,729,732,734,737],{"class":557,"line":725},14,[555,727,728],{"class":638},"    Body",[555,730,731],{"class":696},"      string",[555,733,700],{"class":590},[555,735,736],{"class":662},"json:\"body\"",[555,738,706],{"class":590},[555,740,742,745,748,750,753,756,759],{"class":557,"line":741},15,[555,743,744],{"class":638},"    CreatedAt",[555,746,747],{"class":565}," time",[555,749,649],{"class":583},[555,751,752],{"class":565},"Time",[555,754,755],{"class":590}," `",[555,757,758],{"class":662},"json:\"createdAt\"",[555,760,706],{"class":590},[555,762,764,767,769,771,773,775,778],{"class":557,"line":763},16,[555,765,766],{"class":638},"    UpdatedAt",[555,768,747],{"class":565},[555,770,649],{"class":583},[555,772,752],{"class":565},[555,774,755],{"class":590},[555,776,777],{"class":662},"json:\"updatedAt\"",[555,779,706],{"class":590},[555,781,783],{"class":557,"line":782},17,[555,784,785],{"class":583},"}\n",[555,787,789],{"class":557,"line":788},18,[555,790,573],{"emptyLinePlaceholder":572},[555,792,794,796,799,802],{"class":557,"line":793},19,[555,795,678],{"class":561},[555,797,798],{"class":565}," Store",[555,800,801],{"class":561}," interface",[555,803,687],{"class":583},[555,805,807,810,812,814,816,819,822,825,828,831,834],{"class":557,"line":806},20,[555,808,809],{"class":652},"    List",[555,811,656],{"class":583},[555,813,595],{"class":565},[555,815,649],{"class":583},[555,817,818],{"class":565},"Context",[555,820,821],{"class":583},")",[555,823,824],{"class":583}," ([]",[555,826,827],{"class":565},"Note",[555,829,830],{"class":583},",",[555,832,833],{"class":696}," error",[555,835,624],{"class":583},[555,837,839,842,844,846,848,850,852,855,857,860,862,864,866],{"class":557,"line":838},21,[555,840,841],{"class":652},"    Get",[555,843,656],{"class":583},[555,845,595],{"class":565},[555,847,649],{"class":583},[555,849,818],{"class":565},[555,851,830],{"class":583},[555,853,854],{"class":696}," string",[555,856,821],{"class":583},[555,858,859],{"class":583}," (",[555,861,827],{"class":565},[555,863,830],{"class":583},[555,865,833],{"class":696},[555,867,624],{"class":583},[555,869,871,874,876,878,880,882,884,886,888],{"class":557,"line":870},22,[555,872,873],{"class":652},"    Create",[555,875,656],{"class":583},[555,877,595],{"class":565},[555,879,649],{"class":583},[555,881,818],{"class":565},[555,883,830],{"class":583},[555,885,681],{"class":565},[555,887,821],{"class":583},[555,889,890],{"class":696}," error\n",[555,892,894,897,899,901,903,905,907,909,911],{"class":557,"line":893},23,[555,895,896],{"class":652},"    Replace",[555,898,656],{"class":583},[555,900,595],{"class":565},[555,902,649],{"class":583},[555,904,818],{"class":565},[555,906,830],{"class":583},[555,908,681],{"class":565},[555,910,821],{"class":583},[555,912,890],{"class":696},[555,914,916,919,921,923,925,927,929,931,933],{"class":557,"line":915},24,[555,917,918],{"class":652},"    Delete",[555,920,656],{"class":583},[555,922,595],{"class":565},[555,924,649],{"class":583},[555,926,818],{"class":565},[555,928,830],{"class":583},[555,930,854],{"class":696},[555,932,821],{"class":583},[555,934,890],{"class":696},[555,936,938],{"class":557,"line":937},25,[555,939,785],{"class":583},[394,941,942,943,946,947,950],{},"The domain owns the meaning of a note and ",[456,944,945],{},"ErrNotFound",". It does not know about JSON files, URLs, or HTTP status codes. ",[456,948,949],{},"context.Context"," is the first parameter because callers control cancellation; do not store a context inside a long-lived struct.",[398,952,954],{"id":953},"choose-simple-boundaries","Choose simple boundaries",[546,956,961],{"className":957,"code":959,"language":960,"meta":551},[958],"language-text","HTTP request\n    -> handler: decode, validate, map HTTP details\n        -> service: apply note rules and timestamps\n            -> store: read or persist notes\nHTTP response\n","text",[456,962,959],{"__ignoreMap":551},[394,964,965,966,969,970,973],{},"For a project this size, ",[456,967,968],{},"internal\u002Fnote"," and ",[456,971,972],{},"internal\u002Fhttpapi"," are enough. Add a layer only when it owns a real responsibility. A large directory tree does not make a design clean.",[398,975,977],{"id":976},"error-contract","Error contract",[394,979,980],{},"Handlers may map errors as follows:",[403,982,983,990,999,1005],{},[406,984,985,986,989],{},"invalid client input → ",[456,987,988],{},"400",";",[406,991,992,995,996,989],{},[456,993,994],{},"note.ErrNotFound"," → ",[456,997,998],{},"404",[406,1000,1001,1002,989],{},"unsupported method → ",[456,1003,1004],{},"405",[406,1006,1007,1008,1011],{},"unexpected internal failure → ",[456,1009,1010],{},"500",", with details logged on the server rather than returned to the client.",[394,1013,1014,1015,1018],{},"Use ",[456,1016,1017],{},"errors.Is"," when checking wrapped sentinel errors.",[398,1020,1022],{"id":1021},"practice","Practice",[394,1024,1025,1026,1029,1030,649],{},"Sketch the request path for ",[456,1027,1028],{},"PUT \u002Fnotes\u002Fabc",". Name the responsibility of the handler, service, and store, and state which layer decides that a missing note becomes HTTP ",[456,1031,998],{},[1033,1034,1035],"accordion",{},[1036,1037,1040,1041,1044,1045,1047,1048,1050,1051,1053],"accordion-item",{"icon":1038,"label":1039},"i-lucide-lightbulb","Show solution","The handler decodes the JSON body, checks its size and shape, and reads ",[456,1042,1043],{},"abc"," from the route. The service normalises and validates domain values, sets the update time, and asks the store to replace the note. The store returns ",[456,1046,994],{}," if ",[456,1049,1043],{}," is absent. The handler is the layer that maps that domain error to HTTP ",[456,1052,998],{},", because HTTP is a transport concern.",[398,1055,1057],{"id":1056},"summary","Summary",[403,1059,1060,1063,1066,1069],{},[406,1061,1062],{},"Begin with observable behaviour and a small domain model.",[406,1064,1065],{},"Keep transport, business rules, and persistence separate.",[406,1067,1068],{},"Domain errors cross boundaries; HTTP status codes stay in handlers.",[406,1070,1071],{},"File storage is useful for learning, but it needs explicit durability and concurrency rules.",[1073,1074],"learning-lesson-complete",{},[1076,1077],"learning-lesson-navigation",{"next":341,"nextTitle":340,"previous":330,"previousTitle":1078},"Cancellation and tests",[1080,1081,1082],"style",{},"html pre.shiki code .sEOdo, html code.shiki .sEOdo{--shiki-light:#859900;--shiki-default:#89DDFF;--shiki-dark:#C678DD}html pre.shiki code .snwKR, html code.shiki .snwKR{--shiki-light:#CB4B16;--shiki-default:#FFCB6B;--shiki-dark:#E5C07B}html pre.shiki code .s7Bcg, html code.shiki .s7Bcg{--shiki-light:#859900;--shiki-light-font-style:inherit;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#C678DD;--shiki-dark-font-style:inherit}html pre.shiki code .shFME, html code.shiki .shFME{--shiki-light:#657B83;--shiki-default:#89DDFF;--shiki-dark:#ABB2BF}html pre.shiki code .sED5a, html code.shiki .sED5a{--shiki-light:#2AA198;--shiki-default:#89DDFF;--shiki-dark:#98C379}html pre.shiki code .sdLNw, html code.shiki .sdLNw{--shiki-light:#2AA198;--shiki-default:#FFCB6B;--shiki-dark:#98C379}html pre.shiki code .s45-6, html code.shiki .s45-6{--shiki-light:#268BD2;--shiki-default:#EEFFFF;--shiki-dark:#E06C75}html pre.shiki code .su2KV, html code.shiki .su2KV{--shiki-light:#859900;--shiki-default:#89DDFF;--shiki-dark:#E5C07B}html pre.shiki code .sisdC, html code.shiki .sisdC{--shiki-light:#268BD2;--shiki-default:#82AAFF;--shiki-dark:#61AFEF}html pre.shiki code .sVazx, html code.shiki .sVazx{--shiki-light:#2AA198;--shiki-default:#C3E88D;--shiki-dark:#98C379}html pre.shiki code .sF6sA, html code.shiki .sF6sA{--shiki-light:#586E75;--shiki-light-font-weight:bold;--shiki-default:#C792EA;--shiki-default-font-weight:inherit;--shiki-dark:#C678DD;--shiki-dark-font-weight:inherit}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":551,"searchDepth":569,"depth":569,"links":1084},[1085,1086,1087,1088,1089,1090,1091],{"id":400,"depth":569,"text":401},{"id":423,"depth":569,"text":424},{"id":543,"depth":569,"text":544},{"id":953,"depth":569,"text":954},{"id":976,"depth":569,"text":977},{"id":1021,"depth":569,"text":1022},{"id":1056,"depth":569,"text":1057},"Design an intermediate HTTP API with clear layers, durable JSON storage, and predictable errors.","md",null,{},{"title":338,"description":1092},"FEy7Ldw2Hz1nqDTSYJZ7bNhiK0xXpGZsTFo3FLiJUaE",[1099,1101],{"title":329,"path":330,"stem":331,"description":1100,"icon":173,"children":-1},"Prove worker limits, timeout behaviour, ordering, cleanup, and race-free execution with controlled servers.",{"title":340,"path":341,"stem":342,"description":1102,"children":-1},"Implement snapshot reads, serialized writes, and recoverable file replacement for the notes API.",1794118105657]