Added use method

This commit is contained in:
Ben Ashton 2022-09-28 23:33:08 -06:00
parent a18f52b6a1
commit 928e909f2f
3 changed files with 11 additions and 6 deletions

View File

@ -12,7 +12,7 @@ Here is some leaked source code for my brand new Cat website. Do not steal!
#!/bin/bash #!/bin/bash
printf '%s\n\n' 'Content-Type: text/html'; printf '%s\n\n' 'Content-Type: text/html';
source ../src/exprash.sh; source exprash.sh;
declare -A cats; declare -A cats;
cats[calico]="Calico"; cats[calico]="Calico";
@ -39,7 +39,7 @@ get '/cats/:cat' && {
fi; fi;
} }
all '/cats/:cat' && { use && {
printf '<h1>Error: Cannot find that cat</h1>\n'; printf '<h1>Error: Cannot find that cat</h1>\n';
} }
``` ```

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
printf '%s\n\n' 'Content-Type: text/html'; printf '%s\n\n' 'Content-Type: text/html';
source ../src/exprash.sh; source exprash.sh;
declare -A cats; declare -A cats;
cats[calico]="Calico"; cats[calico]="Calico";
@ -28,6 +28,6 @@ get '/cats/:cat' && {
fi; fi;
} }
all '/cats/:cat' && { use && {
printf '<h1>Error: Cannot find that cat</h1>\n'; printf '<h1>Error: Cannot find that cat</h1>\n';
} }

View File

@ -37,7 +37,12 @@ function all() {
params=(); params=();
pathMatch "$1" params || return 1; pathMatch "$1" params || return 1;
# # if path ooesn't match PATH_INFO: return 1 routeHandled=1;
return 0;
}
function use() {
[ "$routeHandled" -eq 1 ] && return 1;
routeHandled=1; routeHandled=1;
return 0; return 0;
} }