add: temporary CORS headers
add: better sql calls with JOIN
This commit is contained in:
		
							parent
							
								
									6050f1cc5f
								
							
						
					
					
						commit
						5a19e99627
					
				
					 7 changed files with 50 additions and 12 deletions
				
			
		| 
						 | 
				
			
			@ -10,7 +10,7 @@ handler_connection(struct mg_connection *c, int ev, void *p)
 | 
			
		|||
    if (ev == MG_EV_HTTP_REQUEST)
 | 
			
		||||
    {
 | 
			
		||||
        struct http_message *hm = (struct http_message *) p;
 | 
			
		||||
        LOG_DEBUG("new http request for %.*s\n", hm->uri.len, hm->uri.p);
 | 
			
		||||
        LOG_DEBUG("new http %.*s request for %.*s\n", hm->method.len, hm->method.p, hm->uri.len, hm->uri.p);
 | 
			
		||||
 | 
			
		||||
        endpoint_t *endpoint = router_find_endpoint(hm->uri.p, hm->uri.len, &hm->method);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -33,7 +33,11 @@ handler_connection(struct mg_connection *c, int ev, void *p)
 | 
			
		|||
                if(endpoint->method == HTTP_METHOD_OPTIONS)
 | 
			
		||||
                {
 | 
			
		||||
                    char options_header[256]; // TODO make more generic
 | 
			
		||||
                    sprintf(options_header, "Allow: OPTIONS%s%s%s%s\r\n" STANDARD_HEADERS,
 | 
			
		||||
                    sprintf(options_header, "Allow: OPTIONS%s%s%s%s\r\nAccess-Control-Allow-Methods: OPTIONS%s%s%s%s\r\n" STANDARD_HEADERS,
 | 
			
		||||
                            endpoint->options & HTTP_METHOD_GET ? ", GET" : "",
 | 
			
		||||
                            endpoint->options & HTTP_METHOD_POST ? ", POST" : "",
 | 
			
		||||
                            endpoint->options & HTTP_METHOD_PUT ? ", PUT" : "",
 | 
			
		||||
                            endpoint->options & HTTP_METHOD_DELETE ? ", DELETE" : "",
 | 
			
		||||
                            endpoint->options & HTTP_METHOD_GET ? ", GET" : "",
 | 
			
		||||
                            endpoint->options & HTTP_METHOD_POST ? ", POST" : "",
 | 
			
		||||
                            endpoint->options & HTTP_METHOD_PUT ? ", PUT" : "",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue