Efficient JSON parsing in VCL with the frozen parser (see https://github.com/cesanta/frozen) For issues & merge requests please use the gitlab mirror: https://gitlab.com/uplex/varnish/libvmod-frozen
Find a file
Thibaut Artis 0617768738 build: Don't use vcs_vmod_version if not present
Before that, when building from a system without
Git some Makefile steps would fail because without
it vmodtool.py would not generate the required
src/vmod_vcs_version.txt file to be present.
We now check if the file is already present or if
git is installed, if either condition is validated
then src/vmod_vcs_version.txt will be used, if not
it will not be used and a warning will be issued
at configure time.
2025-07-30 11:53:30 +02:00
examples/jwt blobdigest is not used in the example 2022-01-07 16:08:22 +01:00
src build: Don't use vcs_vmod_version if not present 2025-07-30 11:53:30 +02:00
.clang-tidy CI: Introduce clang-tidy 2025-07-30 11:53:30 +02:00
.gitignore Handle src/vmod_vcs_version.txt 2025-05-07 17:58:46 +02:00
.gitlab-ci.yml CI: Add a Gitlab CI pipeline configuration 2025-07-30 11:53:30 +02:00
.gitmodules Update frozen submodule 2023-08-29 13:06:33 +02:00
bootstrap fix make distcheck 2025-05-07 17:58:33 +02:00
configure.ac build: Don't use vcs_vmod_version if not present 2025-07-30 11:53:30 +02:00
INSTALL.rst README refactoring 2025-05-23 14:58:59 +02:00
LICENSE Standardize LICENSE 2022-12-01 16:22:42 +01:00
Makefile.am CI: Add coverage target to Makefile 2025-07-30 11:53:30 +02:00
README.rst README refactoring 2025-05-23 14:58:59 +02:00

===========
vmod_frozen
===========

---------------------
Varnish frozen Module
---------------------

DESCRIPTION
===========

This vmod makes available to VCL the _frozen_ JSON parser with low
overhead: By specifying a set of expected JSON paths, a callback to
the parser is used to track only paths of interest, which can then be
extracted.

Example
    ::

	import frozen;

	sub vcl_init {
	    new jwt_hdr = frozen.parser();
	    jwt_hdr.expect(".alg", type=STRING, null=false, required=true);
	    jwt_hdr.expect(".typ", type=STRING, null=false, required=true);

	    new jwt_payload = frozen.parser();
	    jwt_payload.expect(".attr");

	}

	sub vcl_recv {
	    if (! jwt_hdr.parse(...) ||
		jwt_hdr.extract(".alg") != "RS256" ||
		jwt_hdr.extract(".typ") != "JWT") {
		return (synth(400, "unsupported jwt alg/typ"));
	    }

	    if (! jwt_payload.parse(...)) {
		return (synth(400, "parse error"));
	    }

	    set req.http.something =
		jwt_payload.extract(".attr",
				    null = "<null>", undef = "<undef>");

	    # ...
	}

INSTALLATION
============

See `INSTALL.rst <INSTALL.rst>`_ in the source repository.

SEE ALSO
========

* vcl(7)
* varnishd(1)

COPYRIGHT
=========

::

  Copyright 2018 UPLEX Nils Goroll Systemoptimierung
  All rights reserved
 
  Author: Nils Goroll <nils.goroll@uplex.de>
 
  See LICENSE