Browse Source

Added use method

master
Ben Ashton 2 years ago
parent
commit
928e909f2f
  1. 4
      README.md
  2. 6
      examples/cats.sh
  3. 7
      src/exprash.sh

4
README.md

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

6
examples/cats.sh

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

7
src/exprash.sh

@ -37,7 +37,12 @@ function all() {
params=();
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;
return 0;
}

Loading…
Cancel
Save