def todo_item_delete_handler(http_receive, request): user = controllers.users.todo_user_load_from_decoded_data( http_request_get_decoded_data(request)) item_id_str = http_request_get_param_at_idx(request, 0) result = controllers.items.todo_item_delete_by_id_and_user( item_id_str, user) if (result): response = http_response_json_msg(HTTP_STATUS_OK, "Deleted item!".encode('utf-8')) if todo.RUNTIME == runtime.RUNTIME_TYPE_DEVELOPMENT: http_response_print(response) http_response_send(response, http_receive) http_response_delete(response) else: response = http_response_json_error(HTTP_STATUS_NOT_FOUND, "Item not found".encode('utf-8')) if todo.RUNTIME == runtime.RUNTIME_TYPE_DEVELOPMENT: http_response_print(response) http_response_send(response, http_receive) http_response_delete(response)
def auth_handler(http_receive, request): user = todo_user_load_from_decoded_data( http_request_get_decoded_data(request)) if (user): if (todo.RUNTIME == runtime.RUNTIME_TYPE_DEVELOPMENT): print(user) response = http_response_json_msg(HTTP_STATUS_OK, "okay!".encode('utf-8')) if (todo.RUNTIME == runtime.RUNTIME_TYPE_DEVELOPMENT): http_response_print(response) http_response_send(response, http_receive) http_response_delete(response) else: response = http_response_json_error(HTTP_STATUS_BAD_REQUEST, "Bad user!".encode('utf-8')) if (todo.RUNTIME == runtime.RUNTIME_TYPE_DEVELOPMENT): http_response_print(response) http_response_send(response, http_receive) http_response_delete(response)
def users_handler(http_receive, request): response = http_response_json_msg(HTTP_STATUS_OK, "Users Works!".encode('utf-8')) if (todo.RUNTIME == runtime.RUNTIME_TYPE_DEVELOPMENT): http_response_print(response) http_response_send(response, http_receive) http_response_delete(response)
def todo_catch_all_handler(http_receive, request): response = http_response_json_msg(HTTP_STATUS_OK, "Todo Service!".encode('utf-8')) if (todo.RUNTIME == runtime.RUNTIME_TYPE_DEVELOPMENT): http_response_print(response) http_response_send(response, http_receive) http_response_delete(response)
def users_register_handler(http_receive, request): body = http_request_get_body(request) result = controllers.users.todo_users_register(body) if (result == TODO_ERROR_NONE): response = http_response_json_msg( HTTP_STATUS_OK, "Created a new user!".encode('utf-8')) if (todo.RUNTIME == runtime.RUNTIME_TYPE_DEVELOPMENT): http_response_print(response) http_response_send(response, http_receive) http_response_delete(response) else: todo_error_send_response(result, http_receive)
def todo_item_create_handler(http_receive, request): user = controllers.users.todo_user_load_from_decoded_data( http_request_get_decoded_data(request)) body = http_request_get_body(request) result = controllers.items.todo_item_create(user, body) if (result == TODO_ERROR_NONE): response = http_response_json_msg( HTTP_STATUS_OK, "Created a new item!".encode('utf-8')) if (todo.RUNTIME == runtime.RUNTIME_TYPE_DEVELOPMENT): http_response_print(response) http_response_send(response, http_receive) http_response_delete(response) else: todo_error_send_response(result, http_receive)