diff --git a/README.md b/README.md index c15617b..df86b03 100644 --- a/README.md +++ b/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 '

Error: Cannot find that cat

\n'; } ``` diff --git a/examples/cats.sh b/examples/cats.sh index eadc019..262dedb 100644 --- a/examples/cats.sh +++ b/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 '

Error: Cannot find that cat

\n'; -} \ No newline at end of file +} diff --git a/src/exprash.sh b/src/exprash.sh index 5ba4214..c48ab00 100644 --- a/src/exprash.sh +++ b/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; }