@@ -41,39 +41,39 @@ pub fn serve_http(
41
41
// );
42
42
43
43
let mut m: HashMap < Edn , Edn > = HashMap :: new ( ) ;
44
- m. insert ( Edn :: kwd ( "method" ) , Edn :: kwd ( & request. method ( ) . to_string ( ) ) ) ;
44
+ m. insert ( Edn :: tag ( "method" ) , Edn :: tag ( & request. method ( ) . to_string ( ) ) ) ;
45
45
let url = request. url ( ) . to_string ( ) ;
46
- m. insert ( Edn :: kwd ( "url" ) , Edn :: str ( url. to_owned ( ) ) ) ;
46
+ m. insert ( Edn :: tag ( "url" ) , Edn :: str ( url. to_owned ( ) ) ) ;
47
47
48
48
match url. split_once ( '?' ) {
49
49
Some ( ( path_part, query_part) ) => {
50
- m. insert ( Edn :: kwd ( "path" ) , path_part. into ( ) ) ;
51
- m. insert ( Edn :: kwd ( "querystring" ) , query_part. into ( ) ) ;
50
+ m. insert ( Edn :: tag ( "path" ) , path_part. into ( ) ) ;
51
+ m. insert ( Edn :: tag ( "querystring" ) , query_part. into ( ) ) ;
52
52
let query = querystring:: querify ( query_part) ;
53
53
let mut query_dict = HashMap :: new ( ) ;
54
54
for ( k, v) in query {
55
- query_dict. insert ( Edn :: kwd ( k) , v. into ( ) ) ;
55
+ query_dict. insert ( Edn :: tag ( k) , v. into ( ) ) ;
56
56
}
57
- m. insert ( Edn :: kwd ( "query" ) , Edn :: Map ( query_dict) ) ;
57
+ m. insert ( Edn :: tag ( "query" ) , Edn :: Map ( query_dict) ) ;
58
58
}
59
59
None => {
60
- m. insert ( Edn :: kwd ( "path" ) , url. into ( ) ) ;
61
- m. insert ( Edn :: kwd ( "querystring" ) , "" . into ( ) ) ;
62
- m. insert ( Edn :: kwd ( "query" ) , Edn :: Map ( HashMap :: new ( ) ) ) ;
60
+ m. insert ( Edn :: tag ( "path" ) , url. into ( ) ) ;
61
+ m. insert ( Edn :: tag ( "querystring" ) , "" . into ( ) ) ;
62
+ m. insert ( Edn :: tag ( "query" ) , Edn :: Map ( HashMap :: new ( ) ) ) ;
63
63
}
64
64
}
65
65
66
66
let mut headers: HashMap < Edn , Edn > = HashMap :: new ( ) ;
67
67
68
68
for pair in request. headers ( ) {
69
- headers. insert ( Edn :: kwd ( & pair. field . to_string ( ) ) , Edn :: str ( pair. value . to_string ( ) ) ) ;
69
+ headers. insert ( Edn :: tag ( & pair. field . to_string ( ) ) , Edn :: str ( pair. value . to_string ( ) ) ) ;
70
70
}
71
- m. insert ( Edn :: kwd ( "headers" ) , Edn :: Map ( headers) ) ;
71
+ m. insert ( Edn :: tag ( "headers" ) , Edn :: Map ( headers) ) ;
72
72
73
73
if request. method ( ) != & Method :: Get {
74
74
let mut content = String :: new ( ) ;
75
75
request. as_reader ( ) . read_to_string ( & mut content) . unwrap ( ) ;
76
- m. insert ( Edn :: kwd ( "body" ) , Edn :: Str ( content. to_string ( ) . into_boxed_str ( ) ) ) ;
76
+ m. insert ( Edn :: tag ( "body" ) , Edn :: Str ( content. to_string ( ) . into_boxed_str ( ) ) ) ;
77
77
}
78
78
79
79
let info = Edn :: Map ( m) ;
@@ -102,12 +102,12 @@ fn parse_options(d: &Edn) -> Result<HttpServerOptions, String> {
102
102
port : 4000 ,
103
103
host : String :: from ( "0.0.0.0" ) . into_boxed_str ( ) ,
104
104
} ;
105
- options. port = match m. get ( & Edn :: kwd ( "port" ) ) {
105
+ options. port = match m. get ( & Edn :: tag ( "port" ) ) {
106
106
Some ( Edn :: Number ( port) ) => * port as u16 ,
107
107
None => 4000 ,
108
108
a => return Err ( format ! ( "invalid config for port: {:?}" , a) ) ,
109
109
} ;
110
- options. host = match m. get ( & Edn :: kwd ( "host" ) ) {
110
+ options. host = match m. get ( & Edn :: tag ( "host" ) ) {
111
111
Some ( Edn :: Str ( host) ) => host. to_owned ( ) ,
112
112
None => String :: from ( "0.0.0.0" ) . into_boxed_str ( ) ,
113
113
a => return Err ( format ! ( "invalid config for host: {:?}" , a) ) ,
@@ -126,21 +126,21 @@ fn parse_response(info: &Edn) -> Result<ResponseSkeleton, String> {
126
126
headers : HashMap :: new ( ) ,
127
127
body : String :: from ( "" ) . into_boxed_str ( ) ,
128
128
} ;
129
- res. code = match m. get ( & Edn :: kwd ( "code" ) ) {
129
+ res. code = match m. get ( & Edn :: tag ( "code" ) ) {
130
130
Some ( Edn :: Number ( n) ) => * n as u8 ,
131
131
None => 200 ,
132
132
a => return Err ( format ! ( "invalid code: {:?}" , a) ) ,
133
133
} ;
134
- res. body = match m. get ( & Edn :: kwd ( "body" ) ) {
134
+ res. body = match m. get ( & Edn :: tag ( "body" ) ) {
135
135
Some ( Edn :: Str ( s) ) => s. to_owned ( ) ,
136
136
Some ( a) => a. to_string ( ) . into_boxed_str ( ) ,
137
137
None => String :: from ( "" ) . into_boxed_str ( ) ,
138
138
} ;
139
- res. headers = match m. get ( & Edn :: kwd ( "headers" ) ) {
139
+ res. headers = match m. get ( & Edn :: tag ( "headers" ) ) {
140
140
Some ( Edn :: Map ( m) ) => {
141
141
let mut hs: HashMap < Box < str > , Box < str > > = HashMap :: new ( ) ;
142
142
for ( k, v) in m {
143
- let k: Box < str > = if let Edn :: Keyword ( s) = k {
143
+ let k: Box < str > = if let Edn :: Tag ( s) = k {
144
144
s. to_str ( )
145
145
} else if let Edn :: Str ( s) = k {
146
146
s. to_owned ( )
0 commit comments