<commit_before>package Server;

use strict;
use warnings;

use HTTP::Server::Simple::CGI;
use base qw(HTTP::Server::Simple::CGI);
use CGI qw();
use XML::LibXML;
use Carp;
use Data::Dumper;
use Resource;

my $XML_HEADER = '<?xml version="1.0" encoding="UTF-8"?>'
  . '<?xml-stylesheet href="/css/smeagol.css" type="text/css"?>';

sub _xml_preamble {
    my $type = shift; # resources, resource, agenda or booking
    return $XML_HEADER . '<?xml-stylesheet type="application/xml" href="/xsl/' . $type . '.xsl"?>';
}

# Nota: hauria de funcionar amb "named groups" però només
# s'implementen a partir de perl 5.10. Quina misèria, no?
# A Python fa temps que funcionen...
#
# Dispatcher table. Associates a handler to an URL. Groups in
# the URL pattern are given as parameters to handler.
my %crud_for = (
    '/resources'      => { GET => \&_list_resources, },
    '/resource/(\d+)' => {
        GET    => \&_retrieve_resource,
        DELETE => \&_delete_resource,
        POST   => \&_update_resource,
    },
    '/resource'                     => { POST => \&_create_resource, },
    '/resource/(\d+)/bookings'      => { GET  => \&_list_bookings, },
    '/resource/(\d+)/booking'       => { POST => \&_create_booking, },
    '/resource/(\d+)/booking/(\d+)' => {
        GET    => \&_retrieve_booking,
        POST   => \&_update_booking,
        DELETE => \&_delete_booking,
    },<commit_msg>Al fer el darrer merge m'he equivocat a l'hora d'esborrar un canvi. Crec que ara tot esta en ordre.<commit_after>package Server;

use strict;
use warnings;

use HTTP::Server::Simple::CGI;
use base qw(HTTP::Server::Simple::CGI);
use CGI qw();
use XML::LibXML;
use Carp;
use Data::Dumper;
use Resource;

my $XML_HEADER = my $XML_HEADER = '<?xml version="1.0" encoding="UTF-8"?>'; 

sub _xml_preamble {
    my $type = shift; # resources, resource, agenda or booking
    return $XML_HEADER . '<?xml-stylesheet type="application/xml" href="/xsl/' . $type . '.xsl"?>';
}

# Nota: hauria de funcionar amb "named groups" però només
# s'implementen a partir de perl 5.10. Quina misèria, no?
# A Python fa temps que funcionen...
#
# Dispatcher table. Associates a handler to an URL. Groups in
# the URL pattern are given as parameters to handler.
my %crud_for = (
    '/resources'      => { GET => \&_list_resources, },
    '/resource/(\d+)' => {
        GET    => \&_retrieve_resource,
        DELETE => \&_delete_resource,
        POST   => \&_update_resource,
    },
    '/resource'                     => { POST => \&_create_resource, },
    '/resource/(\d+)/bookings'      => { GET  => \&_list_bookings, },
    '/resource/(\d+)/booking'       => { POST => \&_create_booking, },
    '/resource/(\d+)/booking/(\d+)' => {
        GET    => \&_retrieve_booking,
        POST   => \&_update_booking,
        DELETE => \&_delete_booking,
    },
{'fraction_non_alphanumeric': 0.17297488503714184, 'fraction_numerical': 0.004244782454899187, 'mean_word_length': 2.889958734525447, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 2, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 9}, 'pii_count': 0, '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': '7434854', 'n_tokens_mistral': 1004, 'n_tokens_neox': 966, 'n_words': 253}