Added use method
This commit is contained in:
		
							parent
							
								
									a18f52b6a1
								
							
						
					
					
						commit
						928e909f2f
					
				@ -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';
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
				
			|||||||
@ -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';
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -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;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user