refactor: switch to new ! syntax
							parent
							
								
									f6d5c17cc0
								
							
						
					
					
						commit
						edd9e3fde9
					
				
							
								
								
									
										12
									
								
								client.v
								
								
								
								
							
							
						
						
									
										12
									
								
								client.v
								
								
								
								
							|  | @ -30,7 +30,7 @@ struct Response { | |||
| 	results []Package | ||||
| } | ||||
| 
 | ||||
| fn (c Client) request(params map[string][]string) ?[]Package { | ||||
| fn (c Client) request(params map[string][]string) ![]Package { | ||||
| 	mut param_strings := []string{} | ||||
| 
 | ||||
| 	for k, v in params { | ||||
|  | @ -39,14 +39,14 @@ fn (c Client) request(params map[string][]string) ?[]Package { | |||
| 
 | ||||
| 	url := '$c.url?${param_strings.join('&')}' | ||||
| 
 | ||||
| 	res := http.get(url)? | ||||
| 	res := http.get(url)! | ||||
| 
 | ||||
| 	if res.status_code < 200 || res.status_code >= 300 { | ||||
| 		// temporary | ||||
| 		return error('error') | ||||
| 	} | ||||
| 
 | ||||
| 	data := json.decode(Response, res.body)? | ||||
| 	data := json.decode(Response, res.body)! | ||||
| 
 | ||||
| 	if data.@type == 'error' { | ||||
| 		return error('Server responded with an error: $data.error') | ||||
|  | @ -55,7 +55,7 @@ fn (c Client) request(params map[string][]string) ?[]Package { | |||
| 	return data.results | ||||
| } | ||||
| 
 | ||||
| pub fn (c Client) search_by(arg string, st SearchType) ?[]Package { | ||||
| pub fn (c Client) search_by(arg string, st SearchType) ![]Package { | ||||
| 	params := { | ||||
| 		'v':    ['5'] | ||||
| 		'type': ['search'] | ||||
|  | @ -67,11 +67,11 @@ pub fn (c Client) search_by(arg string, st SearchType) ?[]Package { | |||
| } | ||||
| 
 | ||||
| // search performs a search by name_desc. | ||||
| pub fn (c Client) search(arg string) ?[]Package { | ||||
| pub fn (c Client) search(arg string) ![]Package { | ||||
| 	return c.search_by(arg, .name_desc) | ||||
| } | ||||
| 
 | ||||
| pub fn (c Client) info(pkgs []string) ?[]Package { | ||||
| pub fn (c Client) info(pkgs []string) ![]Package { | ||||
| 	params := { | ||||
| 		'v':     ['5'] | ||||
| 		'type':  ['info'] | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue