balde
master
A microframework for C based on GLib.
Main Page
Related Pages
Data Structures
Data Structures
Data Structure Index
Data Fields
All
Variables
Files
File List
Globals
All
b
Functions
b
Typedefs
Enumerations
Examples
•
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Pages
hello-with-cookies.c
An example with HTTP cookies.
/*
* balde: A microframework for C based on GLib.
* 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
>
balde_response_t
*
hello(
balde_app_t
*app,
balde_request_t
*request)
{
balde_response_t
*rv =
balde_make_response
(
balde_request_get_cookie
(request,
"bola"
));
balde_response_set_cookie
(rv,
"bola"
,
"guda"
, 60, -1, NULL, NULL, FALSE, FALSE);
return
rv;
}
int
main(
int
argc,
char
**argv)
{
balde_app_t
*app =
balde_app_init
();
balde_app_add_url_rule
(app,
"hello"
,
"/"
, BALDE_HTTP_GET, hello);
balde_app_run
(app, argc, argv);
balde_app_free
(app);
return
0;
}
balde_app_add_url_rule
void balde_app_add_url_rule(balde_app_t *app, const gchar *endpoint, const gchar *rule, const balde_http_method_t method, balde_view_func_t view_func)
Adds a view to the balde application.
balde.h
balde public API.
balde_response_set_cookie
void balde_response_set_cookie(balde_response_t *response, const gchar *name, const gchar *value, const gint max_age, const gint64 expires, const gchar *path, const gchar *domain, const gboolean secure, const gboolean http_only)
Sets a cookie.
balde_request_t
balde HTTP request context
Definition:
balde.h:212
balde_response_t
balde HTTP response context
Definition:
balde.h:268
balde_app_free
void balde_app_free(balde_app_t *app)
Free application context memory.
balde_request_get_cookie
const gchar * balde_request_get_cookie(balde_request_t *request, const gchar *name)
Gets a cookie.
balde_app_run
void balde_app_run(balde_app_t *app, gint argc, gchar **argv)
Application main loop.
balde_app_init
balde_app_t * balde_app_init(void)
Initializes the application context.
balde_make_response
balde_response_t * balde_make_response(const gchar *content)
Initialize a response context.
balde_app_t
balde application context
Definition:
balde.h:122
Generated on Sat Aug 13 2022 21:41:33 for balde by
1.8.17