Fossil SCM

json mode now accepts command=string request parameter if path length is 1 (no subcommand was specified).

stephan 2011-10-02 12:41 UTC json-multitag-test
Commit 225fd3dad33e7a945d0ade473ab39cc5110c77b7
1 file changed +14 -1
+14 -1
--- src/json.c
+++ src/json.c
@@ -981,10 +981,23 @@
981981
982982
/* Anything which needs json_getenv() and friends should go after
983983
this point.
984984
*/
985985
986
+ if(1 == cson_array_length_get(g.json.cmd.a)){
987
+ /* special case: if we're at the top path, look for
988
+ a "command" request arg which specifies which command
989
+ to run.
990
+ */
991
+ char const * cmd = json_getenv_cstr("command");
992
+ if(cmd){
993
+ json_string_split(cmd, '/', 0, g.json.cmd.a);
994
+ }
995
+ }
996
+
997
+
998
+
986999
if(!g.json.jsonp && g.json.post.o){
9871000
g.json.jsonp =
9881001
json_getenv_cstr("jsonp")
9891002
/*cson_string_cstr(cson_value_get_string(cson_object_get(g.json.post.o,"jsonp")))*/
9901003
;
@@ -1989,11 +2002,11 @@
19892002
handling.
19902003
*/
19912004
;
19922005
json_main_bootstrap();
19932006
json_mode_bootstrap();
1994
- if( g.argc<3 ){
2007
+ if( 2 > cson_array_length_get(g.json.cmd.a) ){
19952008
goto usage;
19962009
}
19972010
db_find_and_open_repository(0, 0);
19982011
#if 0
19992012
json_warn(FSL_JSON_W_ROW_TO_JSON_FAILED, "Just testing.");
20002013
--- src/json.c
+++ src/json.c
@@ -981,10 +981,23 @@
981
982 /* Anything which needs json_getenv() and friends should go after
983 this point.
984 */
985
 
 
 
 
 
 
 
 
 
 
 
 
 
986 if(!g.json.jsonp && g.json.post.o){
987 g.json.jsonp =
988 json_getenv_cstr("jsonp")
989 /*cson_string_cstr(cson_value_get_string(cson_object_get(g.json.post.o,"jsonp")))*/
990 ;
@@ -1989,11 +2002,11 @@
1989 handling.
1990 */
1991 ;
1992 json_main_bootstrap();
1993 json_mode_bootstrap();
1994 if( g.argc<3 ){
1995 goto usage;
1996 }
1997 db_find_and_open_repository(0, 0);
1998 #if 0
1999 json_warn(FSL_JSON_W_ROW_TO_JSON_FAILED, "Just testing.");
2000
--- src/json.c
+++ src/json.c
@@ -981,10 +981,23 @@
981
982 /* Anything which needs json_getenv() and friends should go after
983 this point.
984 */
985
986 if(1 == cson_array_length_get(g.json.cmd.a)){
987 /* special case: if we're at the top path, look for
988 a "command" request arg which specifies which command
989 to run.
990 */
991 char const * cmd = json_getenv_cstr("command");
992 if(cmd){
993 json_string_split(cmd, '/', 0, g.json.cmd.a);
994 }
995 }
996
997
998
999 if(!g.json.jsonp && g.json.post.o){
1000 g.json.jsonp =
1001 json_getenv_cstr("jsonp")
1002 /*cson_string_cstr(cson_value_get_string(cson_object_get(g.json.post.o,"jsonp")))*/
1003 ;
@@ -1989,11 +2002,11 @@
2002 handling.
2003 */
2004 ;
2005 json_main_bootstrap();
2006 json_mode_bootstrap();
2007 if( 2 > cson_array_length_get(g.json.cmd.a) ){
2008 goto usage;
2009 }
2010 db_find_and_open_repository(0, 0);
2011 #if 0
2012 json_warn(FSL_JSON_W_ROW_TO_JSON_FAILED, "Just testing.");
2013

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button