<commit_before>vcl 4.0;
import std;
import directors;
import rtstatus;

backend default {
	.host = "127.0.0.1";
	.port = "8080";
}
backend server1 {
	.host = "192.168.0.10";
	.port ="8081";
}
backend server2 {
	.host = "192.168.0.10";
	.port = "8082";
}

sub vcl_init {
	new bar = directors.round_robin();
	bar.add_backend(server1);
	bar.add_backend(server2);
	bar.add_backend(default);
}

sub vcl_recv {
	if (req.url ~ "/rtstatus.json") {
		return(synth(700, "OK"));
	}
	if (req.url ~ "/rtstatus") {
		return(synth(800, "OK"));
	}
}

sub vcl_synth {
	if (resp.status == 700) {
		set resp.status = 200;
		synthetic(rtstatus.rtstatus());
		return (deliver);
	}
	if (resp.status == 800) {
		set resp.http.Content-Type = "text/html; charset=utf-8";
		synthetic(std.fileread("/home/arianna/libvmod-rtstatus/src/rtstatus.html"));
		return (deliver);
	}
}



<commit_msg>Updated VCL for the new html() function.<commit_after>vcl 4.0;
import std;
import directors;
import rtstatus;

backend default {
	.host = "127.0.0.1";
	.port = "8080";
}
backend server1 {
	.host = "192.168.0.10";
	.port ="8081";
}
backend server2 {
	.host = "192.168.0.10";
	.port = "8082";
}

sub vcl_init {
	new bar = directors.round_robin();
	bar.add_backend(server1);
	bar.add_backend(server2);
	bar.add_backend(default);
}

sub vcl_recv {
	if (req.url ~ "/rtstatus.json") {
		return(synth(700, "OK"));
	}
	if (req.url ~ "/rtstatus") {
		return(synth(800, "OK"));
	}
}

sub vcl_synth {
	if (resp.status == 700) {
		set resp.status = 200;
		synthetic(rtstatus.rtstatus());
		return (deliver);
	}
	if (resp.status == 800) {
		set resp.status = 200;
		set resp.http.Content-Type = "text/html; charset=utf-8";
		synthetic(rtstatus.html());
		return (deliver);
	}
}




{'fraction_non_alphanumeric': 0.18984420080784767, 'fraction_numerical': 0.06866705135603, 'mean_word_length': 3.661290322580645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3039372', 'n_tokens_mistral': 824, 'n_tokens_neox': 725, 'n_words': 143}