Commit ce450c3f authored by Louis Etienne's avatar Louis Etienne
Browse files

Correction du mode DEBUG plus quelques amélirations par-ci par-là

parent 38db69dc
......@@ -35,7 +35,7 @@ namespace Valse {
* @param callback
* @return EXIT_SUCCESS if no error was detected, else EXIT_ON_ERROR
*/
private int execute_query(string query, Callback? callback = null) {
private int execute_query(string query, Sqlite.Callback? callback = null) {
string errmsg = "";
int ec = db.exec(query, null, out errmsg);
......@@ -62,7 +62,6 @@ namespace Valse {
*/
public string register<G> () {
Type model = typeof (G);
string errmsg = "";
// query est la commande a éxécuter
string query = "CREATE TABLE "; // crée une table ...
query += model.name () + " ( "; // appelée par le nom du modèle
......@@ -181,7 +180,6 @@ namespace Valse {
Type type = typeof (G);
// on crée l'objet à retoruner
Object obj = Object.new (type);
string errmsg = "";
// on crée la requête
string query = "SELECT * FROM ";
query += type.name ();
......
......@@ -52,6 +52,7 @@ namespace Valse {
this.register_mime ("js", "application/javascript");
this.server = new Server(Soup.SERVER_PORT, port);
this.server.add_handler (null, soup_handler);
this.static_files = this.get_static_files_list ();
}
......@@ -133,9 +134,11 @@ namespace Valse {
*/
private void soup_handler (Soup.Server server, Soup.Message msg, string path, GLib.HashTable<string, string>? query, Soup.ClientContext client) {
string debug_message = "";
if (DEBUG) {
DateTime now = new DateTime.now_local ();
print ("[%s] Request on \"%s\" ", now.format (DEBUG_DATE_FORMAT), path);
debug_message = "[%s] Request on \"%s\" -> ".printf (now.format (DEBUG_DATE_FORMAT), path);
}
......@@ -202,7 +205,7 @@ namespace Valse {
}
if (DEBUG) {
print ("-> %s %s %d\n", msg.method, res.mime_type, res.error_code);
debug_message += "%s %s %d\n".printf (msg.method, res.mime_type, res.error_code);
}
hdrs = res.headers;
......@@ -218,10 +221,14 @@ namespace Valse {
}
if (DEBUG && is_static) {
print ("-> %s %s %u\n", msg.method, mime, msg.status_code);
debug_message += "%s %s %u\n".printf (msg.method, mime, msg.status_code);
}
msg.set_response (mime, Soup.MemoryUse.COPY, response);
if (DEBUG) {
print (debug_message);
}
}
/**
......@@ -233,7 +240,6 @@ namespace Valse {
public void register (string route, Controller controller) {
if (!this.routes.has_key (route)) {
this.routes.set (route, controller);
this.server.add_handler (null, soup_handler);
} else {
print ("ERROR: \"/%s\" has already a controller.\n", route);
return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment