Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/writecrow/rest_feedback_endpoint
Drupal module for receiving & emailing feedback form data from a front end
https://github.com/writecrow/rest_feedback_endpoint
drupal rest
Last synced: 15 days ago
JSON representation
Drupal module for receiving & emailing feedback form data from a front end
- Host: GitHub
- URL: https://github.com/writecrow/rest_feedback_endpoint
- Owner: writecrow
- License: gpl-2.0
- Created: 2020-10-04T00:21:50.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-07-09T01:33:08.000Z (over 1 year ago)
- Last Synced: 2024-11-26T06:13:49.008Z (3 months ago)
- Topics: drupal, rest
- Language: PHP
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Feedback Endpoint
This module provides a REST resource endpoint for receiving a POST request and sending an email with the content provided. The example in this module demonstrates feedback form content, but the `SubmitIssue` endpoint can serve as a model for other types of endpoints.## Recommended setup
1. Use the `simple_oauth` module
2. Enable Drupal core's `rest_ui` module.
3. Go to `/admin/config/services/rest` and enable the "Submit an issue" endpoint:
- Granularity: Resource
- Method: POST
- Accepted request formats: json, xml
- Authentication providers: oauth2
4. Set permission for which role(s) may access the endpoint at `/admin/people/permissions#module-rest`
5. Ensure that your endpoint can be reached by configuring your `services.yml` file:```
cors.config:
enabled: true
# Specify allowed headers, like 'x-allowed-header'.
allowedHeaders: ['x-csrf-token','authorization','content-type','accept','origin','x-requested-with', 'access-control-allow-origin','x-allowed-header']
# Specify allowed request methods, specify ['*'] to allow all possible ones.
allowedMethods: ['GET', 'POST']
# Configure requests allowed from specific origins (ideally, limit this to the expected origins)
allowedOrigins: ['*']
# Sets the Access-Control-Expose-Headers header.
exposedHeaders: false
# Sets the Access-Control-Max-Age header.
maxAge: false
# Sets the Access-Control-Allow-Credentials header.
supportsCredentials: false
```If replicating the original demonstration `SubmitIssue`, pay close attention to the annotation, which defines the
route, and must follow an idiosyncratic format to work with POST requests (see https://www.drupal.org/forum/support/post-installation/2017-02-21/post-return-no-route-found-error-while-get-request-is):```
* @RestResource(
* id = "feedback_endpoint_bug_report",
* label = @Translation("Submit an issue"),
* uri_paths = {
* "canonical" = "/submit-issue",
* "create" = "/submit-issue"
* }
* )
```