std.atoi

INTEGERstd.atoiSTRINGs

Available in all subroutines.

Takes a string (which represents an integer) as an argument and returns its value. Behaves as if calling std.strtol with a base of 10.

Example

if (std.atoi(req.http.X-Decimal) == 42) {
set req.http.X-TheAnswer = "Found";
}

Try it out

std.atoi is used in the following solution recipes, which show real world use cases. Click RUN to provision a Fastly service, execute the code on Fastly, and see how the function behaves.

Time-limited URL tokens

Make URLs expire after a configurable period.

User contributed notes

We welcome comments that add use cases, ideas, tips, and caveats. All comments will be moderated before publication. To post support questions, visit our support center and we'll find you the help you need.