import std/http.{Settings} import std/io // The body limit of a request target (ADR 0012, Revision 5): the first // `large_bodies` prefix that matches the path on whole segments, else // `max_body`. pub fn main :: -> () / { let settings = Settings( ..http.defaults () , max_body: 16 , large_bodies: [("/uploads", 64), ("/files/", 32), ("/uploads/big", 128)] ) let limit = fn target { io.println (show (http.body_limit settings target)) } limit "/" //> 16 limit "/uploads" //> 64 limit "/uploads/a/b" //> 64 limit "/uploads?x=1" //> 64 // Not a whole segment. limit "/uploadsx" //> 16 limit "/uploads-old/a" //> 16 // The first match wins, even when a later prefix is longer. limit "/uploads/big" //> 64 // A prefix written with its slash: `/files` itself is not below it. limit "/files/a" //> 32 limit "/files" //> 16 // Matched as written: an escaped spelling gets the default. limit "/upl%6Fads/a" //> 16 limit "/notes/uploads" //> 16 io.println (show (http.body_limit (http.defaults ()) "/uploads")) //> 1048576 }