mirror of
https://github.com/urlysses/1991.git
synced 2024-11-26 03:28:06 +11:00
Basic query string handling.
This commit is contained in:
parent
888cf5ba77
commit
a32c43b989
22
1991.fs
22
1991.fs
@ -37,6 +37,13 @@ pubvar public
|
||||
: get-public-path ( -- addr u )
|
||||
public 2@ ;
|
||||
|
||||
\ Query params
|
||||
pubvar queryString
|
||||
: set-query-string ( addr u -- )
|
||||
queryString 2! ;
|
||||
: get-query-string ( -- addr u )
|
||||
queryString 2@ ;
|
||||
|
||||
\ Request's Content-Type
|
||||
pubvar RequestContentType
|
||||
: set-content-type ( addr u -- )
|
||||
@ -95,8 +102,19 @@ s" image/x-icon" filetype: ico
|
||||
: send-response ( addr u socket -- )
|
||||
dup >r write-socket r> close-socket ;
|
||||
|
||||
: requested-route ( addr u -- routeaddr routeu )
|
||||
bl scan 1- swap 1+ swap 2dup bl scan swap drop - ;
|
||||
: store-query-string ( addr u -- raddr ru )
|
||||
2dup s" ?" search if
|
||||
2dup set-query-string \ store query string
|
||||
swap drop -
|
||||
else
|
||||
s" " set-query-string \ store empty query string (reset)
|
||||
2drop
|
||||
then ;
|
||||
|
||||
: requested-route ( addr u -- raddr ru )
|
||||
bl scan 1- swap 1+ swap
|
||||
2dup bl scan swap drop - \ get the space-separated route
|
||||
store-query-string ; \ strip and store the query, leave route
|
||||
|
||||
: file-exists? ( addr u -- addr u bool )
|
||||
2dup file-status nip 0= ;
|
||||
|
@ -7,7 +7,7 @@ A server-side web framework written in Forth.
|
||||
+ [x] set appropriate mime-types
|
||||
+ [x] file-serving if no user-defined routes match. Search "public/" dir
|
||||
unless otherwise specified by user.
|
||||
+ [ ] query arguments
|
||||
+ [x] query arguments
|
||||
+ [ ] PUT, POST, DELETE
|
||||
+ [ ] templating
|
||||
+ [ ] fuzzy-/pattern-match-enabled user routes (e.g., /something/*/wildcard)?
|
||||
|
Loading…
Reference in New Issue
Block a user