add: endpoint responses
This commit is contained in:
		
							parent
							
								
									5a19e99627
								
							
						
					
					
						commit
						5e64f5963c
					
				
					 18 changed files with 587 additions and 235 deletions
				
			
		| 
						 | 
				
			
			@ -28,6 +28,4 @@
 | 
			
		|||
 | 
			
		||||
#define PIFACE_GPIO_BASE 200
 | 
			
		||||
 | 
			
		||||
#define STANDARD_HEADERS "Access-Control-Allow-Origin: *\r\nAccess-Control-Allow-Headers: *"
 | 
			
		||||
 | 
			
		||||
#endif /* CORE_CONTANTS_H */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,27 +4,27 @@
 | 
			
		|||
#include <router.h>
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
api_v1_controllers_discover_POST(struct mg_connection *c, endpoint_args_t *args, struct http_message *hm);
 | 
			
		||||
api_v1_controllers_discover_POST(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
api_v1_controllers_GET(struct mg_connection *c, endpoint_args_t *args, struct http_message *hm);
 | 
			
		||||
api_v1_controllers_GET(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
api_v1_controllers_STR_GET(struct mg_connection *c, endpoint_args_t *args, struct http_message *hm);
 | 
			
		||||
api_v1_controllers_STR_GET(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
api_v1_controllers_STR_PUT(struct mg_connection *c, endpoint_args_t *args, struct http_message *hm);
 | 
			
		||||
api_v1_controllers_STR_PUT(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
api_v1_controllers_STR_DELETE(struct mg_connection *c, endpoint_args_t *args, struct http_message *hm);
 | 
			
		||||
api_v1_controllers_STR_DELETE(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
api_v1_controllers_STR_relays_GET(struct mg_connection *c, endpoint_args_t *args, struct http_message *hm);
 | 
			
		||||
api_v1_controllers_STR_relays_GET(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
api_v1_controllers_STR_relays_INT_GET(struct mg_connection *c, endpoint_args_t *args, struct http_message *hm);
 | 
			
		||||
api_v1_controllers_STR_relays_INT_GET(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
api_v1_controllers_STR_relays_INT_PUT(struct mg_connection *c, endpoint_args_t *args, struct http_message *hm);
 | 
			
		||||
api_v1_controllers_STR_relays_INT_PUT(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response);
 | 
			
		||||
 | 
			
		||||
#endif /* CORE_ENDPOINTS_API_V1_CONTROLLERS_H */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,9 +4,9 @@
 | 
			
		|||
#include <router.h>
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
api_v1_relays_GET(struct mg_connection *c, endpoint_args_t *args, struct http_message *hm);
 | 
			
		||||
api_v1_relays_GET(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
api_v1_relays_tag_STR_GET(struct mg_connection *c, endpoint_args_t *args, struct http_message *hm);
 | 
			
		||||
api_v1_relays_tag_STR_GET(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response);
 | 
			
		||||
 | 
			
		||||
#endif /* CORE_ENDPOINTS_API_V1_RELAYS_H */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,21 +4,21 @@
 | 
			
		|||
#include <router.h>
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
api_v1_schedules_POST(struct mg_connection *c, endpoint_args_t *args, struct http_message *hm);
 | 
			
		||||
api_v1_schedules_POST(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
api_v1_schedules_GET(struct mg_connection *c, endpoint_args_t *args, struct http_message *hm);
 | 
			
		||||
api_v1_schedules_GET(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
api_v1_schedules_STR_GET(struct mg_connection *c, endpoint_args_t *args, struct http_message *hm);
 | 
			
		||||
api_v1_schedules_STR_GET(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
api_v1_schedules_STR_PUT(struct mg_connection *c, endpoint_args_t *args, struct http_message *hm);
 | 
			
		||||
api_v1_schedules_STR_PUT(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
api_v1_schedules_STR_DELETE(struct mg_connection *c, endpoint_args_t *args, struct http_message *hm);
 | 
			
		||||
api_v1_schedules_STR_DELETE(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
api_v1_schedules_tag_STR_GET(struct mg_connection *c, endpoint_args_t *args, struct http_message *hm);
 | 
			
		||||
api_v1_schedules_tag_STR_GET(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response);
 | 
			
		||||
 | 
			
		||||
#endif /* CORE_ENDPOINTS_API_V1_SCHEDULES_H */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										1
									
								
								include/macros.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								include/macros.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
#define STRLEN(s) ((sizeof(s)/sizeof(s[0])) - sizeof(s[0]))
 | 
			
		||||
| 
						 | 
				
			
			@ -30,7 +30,16 @@ typedef struct
 | 
			
		|||
    } value;
 | 
			
		||||
} endpoint_args_t;
 | 
			
		||||
 | 
			
		||||
typedef void (*endpoint_func_f)(struct mg_connection *c, endpoint_args_t *args, struct http_message *hm);
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
    int status_code;
 | 
			
		||||
    const char *content_type;
 | 
			
		||||
    size_t content_length;
 | 
			
		||||
    const char *content;
 | 
			
		||||
    int alloced_content;
 | 
			
		||||
} endpoint_response_t;
 | 
			
		||||
 | 
			
		||||
typedef void (*endpoint_func_f)(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response);
 | 
			
		||||
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue