[{"data":1,"prerenderedAt":1959},["ShallowReactive",2],{"navigation_docs":3,"-backend-development-middleware":377,"-backend-development-middleware-surround":1954},[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":210,"body":379,"description":1946,"extension":1947,"links":1948,"meta":1949,"navigation":1950,"path":211,"seo":1951,"stem":212,"__hash__":1953},"docs\u002F5.backend-development\u002F3.middleware.md",{"type":380,"value":381,"toc":1934},"minimark",[382,388,393,397,421,425,428,477,480,615,619,751,822,825,829,832,1068,1071,1074,1078,1338,1348,1352,1607,1610,1614,1617,1621,1657,1661,1668,1903,1907,1924,1927,1930],[383,384],"learning-lesson-meta",{"level":385,"prerequisites":386,"time":387},"Intermediate","HTTP API Design, handlers, context, and interfaces","45–55 minutes",[389,390,392],"h2",{"id":391},"what-you-will-learn","What you will learn",[394,395,396],"p",{},"By the end of this lesson, you will be able to:",[398,399,400,409,412,415,418],"ul",{},[401,402,403,404,408],"li",{},"write middleware using ",[405,406,407],"code",{},"func(http.Handler) http.Handler",";",[401,410,411],{},"compose middleware in a deliberate order;",[401,413,414],{},"carry small request-scoped values through context;",[401,416,417],{},"record status codes without breaking response behaviour;",[401,419,420],{},"decide which concerns belong outside middleware.",[389,422,424],{"id":423},"mental-model-a-controlled-wrapper","Mental model: a controlled wrapper",[394,426,427],{},"Middleware receives a handler and returns a handler:",[429,430,435],"pre",{"className":431,"code":432,"language":433,"meta":434,"style":434},"language-go shiki shiki-themes solarized-light material-theme one-dark-pro","type Middleware func(http.Handler) http.Handler\n","go","",[405,436,437],{"__ignoreMap":434},[438,439,442,446,450,453,457,460,463,466,469,472,474],"span",{"class":440,"line":441},"line",1,[438,443,445],{"class":444},"sEOdo","type",[438,447,449],{"class":448},"snwKR"," Middleware",[438,451,452],{"class":444}," func",[438,454,456],{"class":455},"shFME","(",[438,458,459],{"class":448},"http",[438,461,462],{"class":455},".",[438,464,465],{"class":448},"Handler",[438,467,468],{"class":455},")",[438,470,471],{"class":448}," http",[438,473,462],{"class":455},[438,475,476],{"class":448},"Handler\n",[394,478,479],{},"It performs work before the next handler, after it, or both.",[429,481,483],{"className":431,"code":482,"language":433,"meta":434,"style":434},"func Example(next http.Handler) http.Handler {\n    return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n        \u002F\u002F Before\n        next.ServeHTTP(w, r)\n        \u002F\u002F After\n    })\n}\n",[405,484,485,517,568,575,597,603,609],{"__ignoreMap":434},[438,486,487,490,494,496,500,502,504,506,508,510,512,514],{"class":440,"line":441},[438,488,489],{"class":444},"func",[438,491,493],{"class":492},"sisdC"," Example",[438,495,456],{"class":455},[438,497,499],{"class":498},"syre3","next",[438,501,471],{"class":448},[438,503,462],{"class":455},[438,505,465],{"class":448},[438,507,468],{"class":455},[438,509,471],{"class":448},[438,511,462],{"class":455},[438,513,465],{"class":448},[438,515,516],{"class":455}," {\n",[438,518,520,524,527,529,532,534,536,538,541,543,545,548,551,554,557,559,561,564,566],{"class":440,"line":519},2,[438,521,523],{"class":522},"s7Bcg","    return",[438,525,471],{"class":526},"s45-6",[438,528,462],{"class":455},[438,530,531],{"class":492},"HandlerFunc",[438,533,456],{"class":455},[438,535,489],{"class":444},[438,537,456],{"class":455},[438,539,540],{"class":498},"w",[438,542,471],{"class":448},[438,544,462],{"class":455},[438,546,547],{"class":448},"ResponseWriter",[438,549,550],{"class":455},",",[438,552,553],{"class":498}," r",[438,555,556],{"class":444}," *",[438,558,459],{"class":448},[438,560,462],{"class":455},[438,562,563],{"class":448},"Request",[438,565,468],{"class":455},[438,567,516],{"class":455},[438,569,571],{"class":440,"line":570},3,[438,572,574],{"class":573},"sJsHy","        \u002F\u002F Before\n",[438,576,578,581,583,586,588,590,592,594],{"class":440,"line":577},4,[438,579,580],{"class":526},"        next",[438,582,462],{"class":455},[438,584,585],{"class":492},"ServeHTTP",[438,587,456],{"class":455},[438,589,540],{"class":526},[438,591,550],{"class":455},[438,593,553],{"class":526},[438,595,596],{"class":455},")\n",[438,598,600],{"class":440,"line":599},5,[438,601,602],{"class":573},"        \u002F\u002F After\n",[438,604,606],{"class":440,"line":605},6,[438,607,608],{"class":455},"    })\n",[438,610,612],{"class":440,"line":611},7,[438,613,614],{"class":455},"}\n",[389,616,618],{"id":617},"compose-explicitly","Compose explicitly",[429,620,622],{"className":431,"code":621,"language":433,"meta":434,"style":434},"func chain(handler http.Handler, middleware ...Middleware) http.Handler {\n    for index := len(middleware) - 1; index >= 0; index-- {\n        handler = middleware[index](handler)\n    }\n    return handler\n}\n",[405,623,624,663,712,735,740,747],{"__ignoreMap":434},[438,625,626,628,631,633,636,638,640,642,644,647,651,653,655,657,659,661],{"class":440,"line":441},[438,627,489],{"class":444},[438,629,630],{"class":492}," chain",[438,632,456],{"class":455},[438,634,635],{"class":498},"handler",[438,637,471],{"class":448},[438,639,462],{"class":455},[438,641,465],{"class":448},[438,643,550],{"class":455},[438,645,646],{"class":498}," middleware",[438,648,650],{"class":649},"sN42N"," ...",[438,652,210],{"class":448},[438,654,468],{"class":455},[438,656,471],{"class":448},[438,658,462],{"class":455},[438,660,465],{"class":448},[438,662,516],{"class":455},[438,664,665,668,671,675,678,680,683,685,688,692,694,696,700,703,705,707,710],{"class":440,"line":519},[438,666,667],{"class":522},"    for",[438,669,670],{"class":526}," index",[438,672,674],{"class":673},"su2KV"," :=",[438,676,677],{"class":492}," len",[438,679,456],{"class":455},[438,681,682],{"class":526},"middleware",[438,684,468],{"class":455},[438,686,687],{"class":444}," -",[438,689,691],{"class":690},"sAJzr"," 1",[438,693,408],{"class":455},[438,695,670],{"class":526},[438,697,699],{"class":698},"sRBoR"," >=",[438,701,702],{"class":690}," 0",[438,704,408],{"class":455},[438,706,670],{"class":526},[438,708,709],{"class":698},"--",[438,711,516],{"class":455},[438,713,714,717,720,722,725,728,731,733],{"class":440,"line":570},[438,715,716],{"class":526},"        handler",[438,718,719],{"class":673}," =",[438,721,646],{"class":492},[438,723,724],{"class":455},"[",[438,726,727],{"class":448},"index",[438,729,730],{"class":455},"](",[438,732,635],{"class":526},[438,734,596],{"class":455},[438,736,737],{"class":440,"line":577},[438,738,739],{"class":455},"    }\n",[438,741,742,744],{"class":440,"line":599},[438,743,523],{"class":522},[438,745,746],{"class":526}," handler\n",[438,748,749],{"class":440,"line":605},[438,750,614],{"class":455},[429,752,754],{"className":431,"code":753,"language":433,"meta":434,"style":434},"handler := chain(\n    routes,\n    Recover(logger),\n    RequestID,\n    AccessLog(logger),\n    Authenticate(authenticator),\n)\n",[405,755,756,767,775,788,795,806,818],{"__ignoreMap":434},[438,757,758,760,762,764],{"class":440,"line":441},[438,759,635],{"class":526},[438,761,674],{"class":673},[438,763,630],{"class":492},[438,765,766],{"class":455},"(\n",[438,768,769,772],{"class":440,"line":519},[438,770,771],{"class":526},"    routes",[438,773,774],{"class":455},",\n",[438,776,777,780,782,785],{"class":440,"line":570},[438,778,779],{"class":492},"    Recover",[438,781,456],{"class":455},[438,783,784],{"class":526},"logger",[438,786,787],{"class":455},"),\n",[438,789,790,793],{"class":440,"line":577},[438,791,792],{"class":526},"    RequestID",[438,794,774],{"class":455},[438,796,797,800,802,804],{"class":440,"line":599},[438,798,799],{"class":492},"    AccessLog",[438,801,456],{"class":455},[438,803,784],{"class":526},[438,805,787],{"class":455},[438,807,808,811,813,816],{"class":440,"line":605},[438,809,810],{"class":492},"    Authenticate",[438,812,456],{"class":455},[438,814,815],{"class":526},"authenticator",[438,817,787],{"class":455},[438,819,820],{"class":440,"line":611},[438,821,596],{"class":455},[394,823,824],{},"The first item is outermost. Recovery should generally wrap code that might panic. Request ID generation should happen before logging needs the ID. Authentication may run only for protected route groups rather than every endpoint.",[389,826,828],{"id":827},"request-ids","Request IDs",[394,830,831],{},"Use a private context-key type to avoid collisions:",[429,833,835],{"className":431,"code":834,"language":433,"meta":434,"style":434},"type contextKey int\n\nconst requestIDKey contextKey = iota\n\nfunc RequestID(next http.Handler) http.Handler {\n    return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n        requestID := newRequestID()\n        ctx := context.WithValue(r.Context(), requestIDKey, requestID)\n        w.Header().Set(\"X-Request-ID\", requestID)\n        next.ServeHTTP(w, r.WithContext(ctx))\n    })\n}\n",[405,836,837,848,854,871,875,902,942,955,993,1028,1058,1063],{"__ignoreMap":434},[438,838,839,841,844],{"class":440,"line":441},[438,840,445],{"class":444},[438,842,843],{"class":448}," contextKey",[438,845,847],{"class":846},"sF6sA"," int\n",[438,849,850],{"class":440,"line":519},[438,851,853],{"emptyLinePlaceholder":852},true,"\n",[438,855,856,859,863,865,867],{"class":440,"line":570},[438,857,858],{"class":444},"const",[438,860,862],{"class":861},"sry10"," requestIDKey",[438,864,843],{"class":448},[438,866,719],{"class":673},[438,868,870],{"class":869},"sp8Z5"," iota\n",[438,872,873],{"class":440,"line":577},[438,874,853],{"emptyLinePlaceholder":852},[438,876,877,879,882,884,886,888,890,892,894,896,898,900],{"class":440,"line":599},[438,878,489],{"class":444},[438,880,881],{"class":492}," RequestID",[438,883,456],{"class":455},[438,885,499],{"class":498},[438,887,471],{"class":448},[438,889,462],{"class":455},[438,891,465],{"class":448},[438,893,468],{"class":455},[438,895,471],{"class":448},[438,897,462],{"class":455},[438,899,465],{"class":448},[438,901,516],{"class":455},[438,903,904,906,908,910,912,914,916,918,920,922,924,926,928,930,932,934,936,938,940],{"class":440,"line":605},[438,905,523],{"class":522},[438,907,471],{"class":526},[438,909,462],{"class":455},[438,911,531],{"class":492},[438,913,456],{"class":455},[438,915,489],{"class":444},[438,917,456],{"class":455},[438,919,540],{"class":498},[438,921,471],{"class":448},[438,923,462],{"class":455},[438,925,547],{"class":448},[438,927,550],{"class":455},[438,929,553],{"class":498},[438,931,556],{"class":444},[438,933,459],{"class":448},[438,935,462],{"class":455},[438,937,563],{"class":448},[438,939,468],{"class":455},[438,941,516],{"class":455},[438,943,944,947,949,952],{"class":440,"line":611},[438,945,946],{"class":526},"        requestID",[438,948,674],{"class":673},[438,950,951],{"class":492}," newRequestID",[438,953,954],{"class":455},"()\n",[438,956,958,961,963,966,968,971,973,976,978,981,984,986,988,991],{"class":440,"line":957},8,[438,959,960],{"class":526},"        ctx",[438,962,674],{"class":673},[438,964,965],{"class":526}," context",[438,967,462],{"class":455},[438,969,970],{"class":492},"WithValue",[438,972,456],{"class":455},[438,974,975],{"class":526},"r",[438,977,462],{"class":455},[438,979,980],{"class":492},"Context",[438,982,983],{"class":455},"(),",[438,985,862],{"class":526},[438,987,550],{"class":455},[438,989,990],{"class":526}," requestID",[438,992,596],{"class":455},[438,994,996,999,1001,1004,1007,1010,1012,1016,1020,1022,1024,1026],{"class":440,"line":995},9,[438,997,998],{"class":526},"        w",[438,1000,462],{"class":455},[438,1002,1003],{"class":492},"Header",[438,1005,1006],{"class":455},"().",[438,1008,1009],{"class":492},"Set",[438,1011,456],{"class":455},[438,1013,1015],{"class":1014},"sED5a","\"",[438,1017,1019],{"class":1018},"sVazx","X-Request-ID",[438,1021,1015],{"class":1014},[438,1023,550],{"class":455},[438,1025,990],{"class":526},[438,1027,596],{"class":455},[438,1029,1031,1033,1035,1037,1039,1041,1043,1045,1047,1050,1052,1055],{"class":440,"line":1030},10,[438,1032,580],{"class":526},[438,1034,462],{"class":455},[438,1036,585],{"class":492},[438,1038,456],{"class":455},[438,1040,540],{"class":526},[438,1042,550],{"class":455},[438,1044,553],{"class":526},[438,1046,462],{"class":455},[438,1048,1049],{"class":492},"WithContext",[438,1051,456],{"class":455},[438,1053,1054],{"class":526},"ctx",[438,1056,1057],{"class":455},"))\n",[438,1059,1061],{"class":440,"line":1060},11,[438,1062,608],{"class":455},[438,1064,1066],{"class":440,"line":1065},12,[438,1067,614],{"class":455},[394,1069,1070],{},"Validate any incoming request ID before trusting or echoing it. Many services generate their own ID and record an upstream trace identifier separately.",[394,1072,1073],{},"Context values are suitable for small request-scoped metadata such as authenticated identity or tracing IDs. They are not a replacement for normal function parameters.",[389,1075,1077],{"id":1076},"record-response-status","Record response status",[429,1079,1081],{"className":431,"code":1080,"language":433,"meta":434,"style":434},"type statusWriter struct {\n    http.ResponseWriter\n    status int\n}\n\nfunc (w *statusWriter) WriteHeader(status int) {\n    if w.status != 0 {\n        return\n    }\n    w.status = status\n    w.ResponseWriter.WriteHeader(status)\n}\n\nfunc (w *statusWriter) Write(data []byte) (int, error) {\n    if w.status == 0 {\n        w.WriteHeader(http.StatusOK)\n    }\n    return w.ResponseWriter.Write(data)\n}\n",[405,1082,1083,1095,1105,1112,1116,1120,1153,1172,1177,1181,1195,1214,1218,1223,1268,1286,1306,1311,1333],{"__ignoreMap":434},[438,1084,1085,1087,1090,1093],{"class":440,"line":441},[438,1086,445],{"class":444},[438,1088,1089],{"class":448}," statusWriter",[438,1091,1092],{"class":444}," struct",[438,1094,516],{"class":455},[438,1096,1097,1100,1102],{"class":440,"line":519},[438,1098,1099],{"class":448},"    http",[438,1101,462],{"class":455},[438,1103,1104],{"class":448},"ResponseWriter\n",[438,1106,1107,1110],{"class":440,"line":570},[438,1108,1109],{"class":526},"    status",[438,1111,847],{"class":846},[438,1113,1114],{"class":440,"line":577},[438,1115,614],{"class":455},[438,1117,1118],{"class":440,"line":599},[438,1119,853],{"emptyLinePlaceholder":852},[438,1121,1122,1124,1127,1130,1133,1136,1138,1141,1143,1146,1149,1151],{"class":440,"line":605},[438,1123,489],{"class":444},[438,1125,1126],{"class":455}," (",[438,1128,1129],{"class":498},"w ",[438,1131,1132],{"class":444},"*",[438,1134,1135],{"class":448},"statusWriter",[438,1137,468],{"class":455},[438,1139,1140],{"class":492}," WriteHeader",[438,1142,456],{"class":455},[438,1144,1145],{"class":498},"status",[438,1147,1148],{"class":846}," int",[438,1150,468],{"class":455},[438,1152,516],{"class":455},[438,1154,1155,1158,1161,1163,1165,1168,1170],{"class":440,"line":611},[438,1156,1157],{"class":522},"    if",[438,1159,1160],{"class":526}," w",[438,1162,462],{"class":455},[438,1164,1145],{"class":526},[438,1166,1167],{"class":698}," !=",[438,1169,702],{"class":690},[438,1171,516],{"class":455},[438,1173,1174],{"class":440,"line":957},[438,1175,1176],{"class":522},"        return\n",[438,1178,1179],{"class":440,"line":995},[438,1180,739],{"class":455},[438,1182,1183,1186,1188,1190,1192],{"class":440,"line":1030},[438,1184,1185],{"class":526},"    w",[438,1187,462],{"class":455},[438,1189,1145],{"class":526},[438,1191,719],{"class":673},[438,1193,1194],{"class":526}," status\n",[438,1196,1197,1199,1201,1203,1205,1208,1210,1212],{"class":440,"line":1060},[438,1198,1185],{"class":526},[438,1200,462],{"class":455},[438,1202,547],{"class":526},[438,1204,462],{"class":455},[438,1206,1207],{"class":492},"WriteHeader",[438,1209,456],{"class":455},[438,1211,1145],{"class":526},[438,1213,596],{"class":455},[438,1215,1216],{"class":440,"line":1065},[438,1217,614],{"class":455},[438,1219,1221],{"class":440,"line":1220},13,[438,1222,853],{"emptyLinePlaceholder":852},[438,1224,1226,1228,1230,1232,1234,1236,1238,1241,1243,1246,1249,1252,1254,1256,1259,1261,1264,1266],{"class":440,"line":1225},14,[438,1227,489],{"class":444},[438,1229,1126],{"class":455},[438,1231,1129],{"class":498},[438,1233,1132],{"class":444},[438,1235,1135],{"class":448},[438,1237,468],{"class":455},[438,1239,1240],{"class":492}," Write",[438,1242,456],{"class":455},[438,1244,1245],{"class":498},"data",[438,1247,1248],{"class":455}," []",[438,1250,1251],{"class":846},"byte",[438,1253,468],{"class":455},[438,1255,1126],{"class":455},[438,1257,1258],{"class":846},"int",[438,1260,550],{"class":455},[438,1262,1263],{"class":846}," error",[438,1265,468],{"class":455},[438,1267,516],{"class":455},[438,1269,1271,1273,1275,1277,1279,1282,1284],{"class":440,"line":1270},15,[438,1272,1157],{"class":522},[438,1274,1160],{"class":526},[438,1276,462],{"class":455},[438,1278,1145],{"class":526},[438,1280,1281],{"class":698}," ==",[438,1283,702],{"class":690},[438,1285,516],{"class":455},[438,1287,1289,1291,1293,1295,1297,1299,1301,1304],{"class":440,"line":1288},16,[438,1290,998],{"class":526},[438,1292,462],{"class":455},[438,1294,1207],{"class":492},[438,1296,456],{"class":455},[438,1298,459],{"class":526},[438,1300,462],{"class":455},[438,1302,1303],{"class":526},"StatusOK",[438,1305,596],{"class":455},[438,1307,1309],{"class":440,"line":1308},17,[438,1310,739],{"class":455},[438,1312,1314,1316,1318,1320,1322,1324,1327,1329,1331],{"class":440,"line":1313},18,[438,1315,523],{"class":522},[438,1317,1160],{"class":526},[438,1319,462],{"class":455},[438,1321,547],{"class":526},[438,1323,462],{"class":455},[438,1325,1326],{"class":492},"Write",[438,1328,456],{"class":455},[438,1330,1245],{"class":526},[438,1332,596],{"class":455},[438,1334,1336],{"class":440,"line":1335},19,[438,1337,614],{"class":455},[394,1339,1340,1341,1343,1344,1347],{},"Wrapping ",[405,1342,547],{}," can hide optional interfaces used by streaming, connection takeover, or optimised copying. On modern Go versions, ",[405,1345,1346],{},"http.ResponseController"," can access supported capabilities without requiring every wrapper to expose each optional interface manually. Test the behaviours your server needs.",[389,1349,1351],{"id":1350},"recover-at-the-http-boundary","Recover at the HTTP boundary",[429,1353,1355],{"className":431,"code":1354,"language":433,"meta":434,"style":434},"func Recover(logger *slog.Logger) Middleware {\n    return func(next http.Handler) http.Handler {\n        return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n            defer func() {\n                if recovered := recover(); recovered != nil {\n                    logger.ErrorContext(r.Context(), \"handler panic\", \"panic\", recovered)\n                    http.Error(w, \"Internal Server Error\", http.StatusInternalServerError)\n                }\n            }()\n            next.ServeHTTP(w, r)\n        })\n    }\n}\n",[405,1356,1357,1384,1410,1451,1463,1488,1531,1565,1570,1575,1594,1599,1603],{"__ignoreMap":434},[438,1358,1359,1361,1364,1366,1368,1370,1373,1375,1378,1380,1382],{"class":440,"line":441},[438,1360,489],{"class":444},[438,1362,1363],{"class":492}," Recover",[438,1365,456],{"class":455},[438,1367,784],{"class":498},[438,1369,556],{"class":444},[438,1371,1372],{"class":448},"slog",[438,1374,462],{"class":455},[438,1376,1377],{"class":448},"Logger",[438,1379,468],{"class":455},[438,1381,449],{"class":448},[438,1383,516],{"class":455},[438,1385,1386,1388,1390,1392,1394,1396,1398,1400,1402,1404,1406,1408],{"class":440,"line":519},[438,1387,523],{"class":522},[438,1389,452],{"class":444},[438,1391,456],{"class":455},[438,1393,499],{"class":498},[438,1395,471],{"class":448},[438,1397,462],{"class":455},[438,1399,465],{"class":448},[438,1401,468],{"class":455},[438,1403,471],{"class":448},[438,1405,462],{"class":455},[438,1407,465],{"class":448},[438,1409,516],{"class":455},[438,1411,1412,1415,1417,1419,1421,1423,1425,1427,1429,1431,1433,1435,1437,1439,1441,1443,1445,1447,1449],{"class":440,"line":570},[438,1413,1414],{"class":522},"        return",[438,1416,471],{"class":526},[438,1418,462],{"class":455},[438,1420,531],{"class":492},[438,1422,456],{"class":455},[438,1424,489],{"class":444},[438,1426,456],{"class":455},[438,1428,540],{"class":498},[438,1430,471],{"class":448},[438,1432,462],{"class":455},[438,1434,547],{"class":448},[438,1436,550],{"class":455},[438,1438,553],{"class":498},[438,1440,556],{"class":444},[438,1442,459],{"class":448},[438,1444,462],{"class":455},[438,1446,563],{"class":448},[438,1448,468],{"class":455},[438,1450,516],{"class":455},[438,1452,1453,1456,1458,1461],{"class":440,"line":577},[438,1454,1455],{"class":522},"            defer",[438,1457,452],{"class":444},[438,1459,1460],{"class":455},"()",[438,1462,516],{"class":455},[438,1464,1465,1468,1471,1473,1476,1479,1481,1483,1486],{"class":440,"line":599},[438,1466,1467],{"class":522},"                if",[438,1469,1470],{"class":526}," recovered",[438,1472,674],{"class":673},[438,1474,1475],{"class":492}," recover",[438,1477,1478],{"class":455},"();",[438,1480,1470],{"class":526},[438,1482,1167],{"class":698},[438,1484,1485],{"class":869}," nil",[438,1487,516],{"class":455},[438,1489,1490,1493,1495,1498,1500,1502,1504,1506,1508,1511,1514,1516,1518,1520,1523,1525,1527,1529],{"class":440,"line":605},[438,1491,1492],{"class":526},"                    logger",[438,1494,462],{"class":455},[438,1496,1497],{"class":492},"ErrorContext",[438,1499,456],{"class":455},[438,1501,975],{"class":526},[438,1503,462],{"class":455},[438,1505,980],{"class":492},[438,1507,983],{"class":455},[438,1509,1510],{"class":1014}," \"",[438,1512,1513],{"class":1018},"handler panic",[438,1515,1015],{"class":1014},[438,1517,550],{"class":455},[438,1519,1510],{"class":1014},[438,1521,1522],{"class":1018},"panic",[438,1524,1015],{"class":1014},[438,1526,550],{"class":455},[438,1528,1470],{"class":526},[438,1530,596],{"class":455},[438,1532,1533,1536,1538,1541,1543,1545,1547,1549,1552,1554,1556,1558,1560,1563],{"class":440,"line":611},[438,1534,1535],{"class":526},"                    http",[438,1537,462],{"class":455},[438,1539,1540],{"class":492},"Error",[438,1542,456],{"class":455},[438,1544,540],{"class":526},[438,1546,550],{"class":455},[438,1548,1510],{"class":1014},[438,1550,1551],{"class":1018},"Internal Server Error",[438,1553,1015],{"class":1014},[438,1555,550],{"class":455},[438,1557,471],{"class":526},[438,1559,462],{"class":455},[438,1561,1562],{"class":526},"StatusInternalServerError",[438,1564,596],{"class":455},[438,1566,1567],{"class":440,"line":957},[438,1568,1569],{"class":455},"                }\n",[438,1571,1572],{"class":440,"line":995},[438,1573,1574],{"class":455},"            }()\n",[438,1576,1577,1580,1582,1584,1586,1588,1590,1592],{"class":440,"line":1030},[438,1578,1579],{"class":526},"            next",[438,1581,462],{"class":455},[438,1583,585],{"class":492},[438,1585,456],{"class":455},[438,1587,540],{"class":526},[438,1589,550],{"class":455},[438,1591,553],{"class":526},[438,1593,596],{"class":455},[438,1595,1596],{"class":440,"line":1060},[438,1597,1598],{"class":455},"        })\n",[438,1600,1601],{"class":440,"line":1065},[438,1602,739],{"class":455},[438,1604,1605],{"class":440,"line":1220},[438,1606,614],{"class":455},[394,1608,1609],{},"Recovery keeps one handler panic from terminating the process, but the response may already be partially written. A panic still represents a defect that should be investigated. Do not use recovery instead of normal errors.",[389,1611,1613],{"id":1612},"what-should-not-be-generic-middleware","What should not be generic middleware?",[394,1615,1616],{},"Business validation, database transactions, and use-case-specific authorization often belong in the application flow because they need domain information. Forcing them into generic wrappers can hide important decisions.",[389,1618,1620],{"id":1619},"common-mistakes","Common mistakes",[398,1622,1623,1630,1639,1645,1651],{},[401,1624,1625,1629],{},[1626,1627,1628],"strong",{},"Unknown middleware order:"," logging misses request IDs or recovery misses an inner wrapper.",[401,1631,1632,1638],{},[1626,1633,1634,1635,1637],{},"Writing a response and still calling ",[405,1636,499],{},":"," two handlers compete to write headers and bodies.",[401,1640,1641,1644],{},[1626,1642,1643],{},"Using string context keys:"," unrelated packages can collide.",[401,1646,1647,1650],{},[1626,1648,1649],{},"Trusting forwarded headers from any client:"," only honour them behind configured trusted proxies.",[401,1652,1653,1656],{},[1626,1654,1655],{},"Adding every concern globally:"," public health endpoints and authenticated business routes may need different chains.",[389,1658,1660],{"id":1659},"practice","Practice",[394,1662,1663,1664,1667],{},"Implement request ID, access logging, and recovery middleware. Compose them so a panic is logged with its request ID and becomes a safe ",[405,1665,1666],{},"500"," response. Test normal, explicit error, and panic handlers.",[1669,1670,1671],"accordion",{},[1672,1673,1676,1679,1897],"accordion-item",{"icon":1674,"label":1675},"i-lucide-lightbulb","Show test strategy",[394,1677,1678],{},"Create three tiny handlers and send each through the full chain:",[429,1680,1682],{"className":431,"code":1681,"language":433,"meta":434,"style":434},"normal := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n    w.WriteHeader(http.StatusNoContent)\n})\n\nfailing := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n    http.Error(w, \"bad request\", http.StatusBadRequest)\n})\n\npanicking := http.HandlerFunc(func(http.ResponseWriter, *http.Request) {\n    panic(\"test panic\")\n})\n",[405,1683,1684,1727,1746,1751,1755,1798,1830,1834,1838,1877,1893],{"__ignoreMap":434},[438,1685,1686,1689,1691,1693,1695,1697,1699,1701,1703,1705,1707,1709,1711,1713,1715,1717,1719,1721,1723,1725],{"class":440,"line":441},[438,1687,1688],{"class":526},"normal",[438,1690,674],{"class":673},[438,1692,471],{"class":526},[438,1694,462],{"class":455},[438,1696,531],{"class":492},[438,1698,456],{"class":455},[438,1700,489],{"class":444},[438,1702,456],{"class":455},[438,1704,540],{"class":498},[438,1706,471],{"class":448},[438,1708,462],{"class":455},[438,1710,547],{"class":448},[438,1712,550],{"class":455},[438,1714,553],{"class":498},[438,1716,556],{"class":444},[438,1718,459],{"class":448},[438,1720,462],{"class":455},[438,1722,563],{"class":448},[438,1724,468],{"class":455},[438,1726,516],{"class":455},[438,1728,1729,1731,1733,1735,1737,1739,1741,1744],{"class":440,"line":519},[438,1730,1185],{"class":526},[438,1732,462],{"class":455},[438,1734,1207],{"class":492},[438,1736,456],{"class":455},[438,1738,459],{"class":526},[438,1740,462],{"class":455},[438,1742,1743],{"class":526},"StatusNoContent",[438,1745,596],{"class":455},[438,1747,1748],{"class":440,"line":570},[438,1749,1750],{"class":455},"})\n",[438,1752,1753],{"class":440,"line":577},[438,1754,853],{"emptyLinePlaceholder":852},[438,1756,1757,1760,1762,1764,1766,1768,1770,1772,1774,1776,1778,1780,1782,1784,1786,1788,1790,1792,1794,1796],{"class":440,"line":599},[438,1758,1759],{"class":526},"failing",[438,1761,674],{"class":673},[438,1763,471],{"class":526},[438,1765,462],{"class":455},[438,1767,531],{"class":492},[438,1769,456],{"class":455},[438,1771,489],{"class":444},[438,1773,456],{"class":455},[438,1775,540],{"class":498},[438,1777,471],{"class":448},[438,1779,462],{"class":455},[438,1781,547],{"class":448},[438,1783,550],{"class":455},[438,1785,553],{"class":498},[438,1787,556],{"class":444},[438,1789,459],{"class":448},[438,1791,462],{"class":455},[438,1793,563],{"class":448},[438,1795,468],{"class":455},[438,1797,516],{"class":455},[438,1799,1800,1802,1804,1806,1808,1810,1812,1814,1817,1819,1821,1823,1825,1828],{"class":440,"line":605},[438,1801,1099],{"class":526},[438,1803,462],{"class":455},[438,1805,1540],{"class":492},[438,1807,456],{"class":455},[438,1809,540],{"class":526},[438,1811,550],{"class":455},[438,1813,1510],{"class":1014},[438,1815,1816],{"class":1018},"bad request",[438,1818,1015],{"class":1014},[438,1820,550],{"class":455},[438,1822,471],{"class":526},[438,1824,462],{"class":455},[438,1826,1827],{"class":526},"StatusBadRequest",[438,1829,596],{"class":455},[438,1831,1832],{"class":440,"line":611},[438,1833,1750],{"class":455},[438,1835,1836],{"class":440,"line":957},[438,1837,853],{"emptyLinePlaceholder":852},[438,1839,1840,1843,1845,1847,1849,1851,1853,1855,1857,1859,1861,1863,1865,1867,1869,1871,1873,1875],{"class":440,"line":995},[438,1841,1842],{"class":526},"panicking",[438,1844,674],{"class":673},[438,1846,471],{"class":526},[438,1848,462],{"class":455},[438,1850,531],{"class":492},[438,1852,456],{"class":455},[438,1854,489],{"class":444},[438,1856,456],{"class":455},[438,1858,459],{"class":448},[438,1860,462],{"class":455},[438,1862,547],{"class":448},[438,1864,550],{"class":455},[438,1866,556],{"class":444},[438,1868,459],{"class":448},[438,1870,462],{"class":455},[438,1872,563],{"class":448},[438,1874,468],{"class":455},[438,1876,516],{"class":455},[438,1878,1879,1882,1884,1886,1889,1891],{"class":440,"line":1030},[438,1880,1881],{"class":492},"    panic",[438,1883,456],{"class":455},[438,1885,1015],{"class":1014},[438,1887,1888],{"class":1018},"test panic",[438,1890,1015],{"class":1014},[438,1892,596],{"class":455},[438,1894,1895],{"class":440,"line":1060},[438,1896,1750],{"class":455},[394,1898,1899,1900,1902],{},"For each case, assert the status, ",[405,1901,1019],{},", and captured log attributes. The panic test should assert a safe body rather than the panic value. A real logging test uses a capturing handler or structured record collector instead of parsing unstable timestamps.",[389,1904,1906],{"id":1905},"summary","Summary",[398,1908,1909,1912,1915,1918,1921],{},[401,1910,1911],{},"Middleware wraps handlers with shared transport-level behaviour.",[401,1913,1914],{},"Composition order changes observable behaviour and must be tested.",[401,1916,1917],{},"Context carries small request-scoped metadata, not arbitrary dependencies.",[401,1919,1920],{},"Response wrappers must preserve the capabilities an application uses.",[401,1922,1923],{},"Keep use-case-specific business decisions in application code.",[1925,1926],"learning-lesson-complete",{},[1928,1929],"learning-lesson-navigation",{"next":216,"next-label":215,"previous":206,"previous-label":205},[1931,1932,1933],"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 .shFME, html code.shiki .shFME{--shiki-light:#657B83;--shiki-default:#89DDFF;--shiki-dark:#ABB2BF}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);}html pre.shiki code .sisdC, html code.shiki .sisdC{--shiki-light:#268BD2;--shiki-default:#82AAFF;--shiki-dark:#61AFEF}html pre.shiki code .syre3, html code.shiki .syre3{--shiki-light:#657B83;--shiki-light-font-style:inherit;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#E06C75;--shiki-dark-font-style:italic}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 .s45-6, html code.shiki .s45-6{--shiki-light:#268BD2;--shiki-default:#EEFFFF;--shiki-dark:#E06C75}html pre.shiki code .sJsHy, html code.shiki .sJsHy{--shiki-light:#93A1A1;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#7F848E;--shiki-dark-font-style:italic}html pre.shiki code .sN42N, html code.shiki .sN42N{--shiki-light:#859900;--shiki-default:#89DDFF;--shiki-dark:#ABB2BF}html pre.shiki code .su2KV, html code.shiki .su2KV{--shiki-light:#859900;--shiki-default:#89DDFF;--shiki-dark:#E5C07B}html pre.shiki code .sAJzr, html code.shiki .sAJzr{--shiki-light:#D33682;--shiki-default:#F78C6C;--shiki-dark:#D19A66}html pre.shiki code .sRBoR, html code.shiki .sRBoR{--shiki-light:#859900;--shiki-default:#89DDFF;--shiki-dark:#56B6C2}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 pre.shiki code .sry10, html code.shiki .sry10{--shiki-light:#268BD2;--shiki-default:#EEFFFF;--shiki-dark:#E5C07B}html pre.shiki code .sp8Z5, html code.shiki .sp8Z5{--shiki-light:#B58900;--shiki-default:#89DDFF;--shiki-dark:#D19A66}html pre.shiki code .sED5a, html code.shiki .sED5a{--shiki-light:#2AA198;--shiki-default:#89DDFF;--shiki-dark:#98C379}html pre.shiki code .sVazx, html code.shiki .sVazx{--shiki-light:#2AA198;--shiki-default:#C3E88D;--shiki-dark:#98C379}",{"title":434,"searchDepth":519,"depth":519,"links":1935},[1936,1937,1938,1939,1940,1941,1942,1943,1944,1945],{"id":391,"depth":519,"text":392},{"id":423,"depth":519,"text":424},{"id":617,"depth":519,"text":618},{"id":827,"depth":519,"text":828},{"id":1076,"depth":519,"text":1077},{"id":1350,"depth":519,"text":1351},{"id":1612,"depth":519,"text":1613},{"id":1619,"depth":519,"text":1620},{"id":1659,"depth":519,"text":1660},{"id":1905,"depth":519,"text":1906},"Wrap HTTP handlers for shared behaviour while preserving correctness and clear ordering.","md",null,{},{"icon":213},{"description":1952,"title":210},"Learn Go net\u002Fhttp middleware composition, request IDs, recovery, logging, response wrapping, ordering, and tests.","h_PU0rKZH1C-ENPm9tZteHspl6H76U3HhU_QMWDfThg",[1955,1957],{"title":205,"path":206,"stem":207,"description":1956,"icon":208,"children":-1},"Design predictable resources, methods, status codes, JSON contracts, and error responses.",{"title":215,"path":216,"stem":217,"description":1958,"icon":218,"children":-1},"Validate request shape, domain rules, and storage invariants at the correct boundaries.",1794118101729]