balde  master
A microframework for C based on GLib and bad intentions.
hello-with-url_for.c

An example with the url_for helper. It depends on more files. Take a look at it on the balde source code.

/*
* balde: A microframework for C based on GLib and bad intentions.
* Copyright (C) 2013-2017 Rafael G. Martins <rafael@rafaelmartins.eng.br>
*
* This program can be distributed under the terms of the LGPL-2 License.
* See the file COPYING.
*/
#include <balde.h>
#include "templates/url_for.h"
home(balde_app_t *app, balde_request_t *request)
{
balde_template_url_for(app, request, response);
return response;
}
profile(balde_app_t *app, balde_request_t *request)
{
const gchar *name = balde_request_get_view_arg(request, "name");
gchar *str = g_strdup_printf("Hello, %s\n", name != NULL ? name : "World");
g_free(str);
return response;
}
int
main(int argc, char **argv)
{
balde_app_add_url_rule(app, "home", "/", BALDE_HTTP_GET, home);
balde_app_add_url_rule(app, "profile", "/profile/<name>/", BALDE_HTTP_GET, profile);
balde_app_run(app, argc, argv);
return 0;
}