BEGIN
ORDS.ENABLE_SCHEMA(
p_enabled => TRUE,
p_schema => 'WKSP_BLOG',
p_url_mapping_type => 'BASE_PATH',
p_url_mapping_pattern => 'trn_apex23',
p_auto_rest_auth => FALSE);
ORDS.DEFINE_MODULE(
p_module_name => 'basic_auth',
p_base_path => '/kubicek-consulting-blog/',
p_items_per_page => 25,
p_status => 'PUBLISHED',
p_comments => 'This is a basic authentication example.');
ORDS.DEFINE_TEMPLATE(
p_module_name => 'basic_auth',
p_pattern => 'emp_json',
p_priority => 0,
p_etag_type => 'HASH',
p_etag_query => NULL,
p_comments => NULL);
ORDS.DEFINE_HANDLER(
p_module_name => 'basic_auth',
p_pattern => 'emp_json',
p_method => 'POST',
p_source_type => 'plsql/block',
p_items_per_page => 0,
p_mimes_allowed => '',
p_comments => NULL,
p_source =>
'DECLARE
v_json VARCHAR2(32767);
v_status_code VARCHAR2(400);
v_error_message VARCHAR2(400);
v_exception EXCEPTION;
BEGIN
rest_basic_auth_pkg.get_emp_json(v_json, v_status_code, v_error_message);
IF v_status_code IS NOT NULL THEN
RAISE v_exception;
ELSE
htp.prn(v_json);
END IF;
EXCEPTION
WHEN v_exception THEN
:string_out := v_error_message;
:status_code := v_status_code;
END;'
);
ORDS.DEFINE_PARAMETER(
p_module_name => 'basic_auth',
p_pattern => 'emp_json',
p_method => 'POST',
p_name => 'message',
p_bind_variable_name => 'string_out',
p_source_type => 'RESPONSE',
p_param_type => 'STRING',
p_access_method => 'OUT',
p_comments => NULL);
ORDS.DEFINE_PARAMETER(
p_module_name => 'basic_auth',
p_pattern => 'emp_json',
p_method => 'POST',
p_name => 'X-ORDS-STATUS-CODE',
p_bind_variable_name => 'status_code',
p_source_type => 'HEADER',
p_param_type => 'STRING',
p_access_method => 'OUT',
p_comments => NULL);
COMMIT;
END;
/