allow "key" to be passed as a parameter
This was initially designed and implemented in #4 Co-authored-by: Sven Seeberg <mail@sven-seeberg.de>
This commit is contained in:
		
					parent
					
						
							
								292d77274d
							
						
					
				
			
			
				commit
				
					
						fa8f9b4a51
					
				
			
		
					 4 changed files with 24 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -38,10 +38,14 @@ async def handler(request):
 | 
			
		|||
    except json.decoder.JSONDecodeError:
 | 
			
		||||
        return create_json_response(HTTPStatus.BAD_REQUEST, "Invalid JSON")
 | 
			
		||||
 | 
			
		||||
    # legacy naming:
 | 
			
		||||
    # legacy naming
 | 
			
		||||
    if "text" in data and "body" not in data:
 | 
			
		||||
        data["body"] = data["text"]
 | 
			
		||||
 | 
			
		||||
    # allow key to be passed as a parameter
 | 
			
		||||
    if "key" in request.rel_url.query and "key" not in data:
 | 
			
		||||
        data["key"] = request.rel_url.query["key"]
 | 
			
		||||
 | 
			
		||||
    if not all(key in data for key in ["body", "key"]):
 | 
			
		||||
        return create_json_response(
 | 
			
		||||
            HTTPStatus.BAD_REQUEST, "Missing body and/or API key property"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue