Skip to content

API Form Handling

Andy Lo edited this page May 4, 2018 · 2 revisions

Contact form

The contact form is located at https://www.sdgreporting.org/contact/.

Functional synopsis

When a contact form submission is received by the API, some basic input sanitation procedures are performed before inserting the submitted data into a formatted e-mail, which is then sent out to the proper (i.e. configured) e-mail address.

The URL that the contact form submits to can be set via Jekyll's configurations.

Configuring the form submission URLs

The forms both look for a setting called api_url to provide the base URL for the API, and then submits via a POST request to their respective endpoints (contact_form or submission_form). The base API URL is currently the only setting in this project that is handled via Jekyll's configuration system.

Since this setting likely depends on your deployment environment, it's best if there are separate environment-specific configuration files for each type of deployment environment.

The current convention I use for naming each environment-specific file follows the format of config-environment.yml. For example, config-development.yml should contain local development settings.

Resource submission form

The resource submission form is located at https://www.sdgreporting.org/submit-resource/.

Functional synopsis

This works much the same way that the contact form does. A POST request is sent to the submission-form endpoint upon form submission.

When a resource submission form is received by the API, the data is passed through some basic input sanitation procedures before being compiled into records to be written to the database.

After the records are written, the data is inserted into a formatted alert e-mail, which is then sent to the configured address.

Clone this wiki locally