-
Notifications
You must be signed in to change notification settings - Fork 393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use custom HTTP routes with parameters or query strings #1325
Comments
Hi @albarivas! 👋🏼 Thanks for bringing this to our attention. Currently, there is no support for parameters, but we agree it would make for an excellent enhancement. We'll get to work on introducing this functionality soon and will link this issue when the corresponding PR is opened. Stay tuned! You mention in the title of this issue being unable to utilize query strings: can you provide the use case/code snippet in which that fails? |
I have just seen your comment and I haven't tried this code, but if I remember correctly:
And then trying to do |
is there any process? |
Hello all! Meant to return to this soon after the changes in #1785 were released, but happy to share that this is now possible! Using const app = new App({
token: process.env.SLACK_BOT_TOKEN,
signingSecret: process.env.SLACK_SIGNING_SECRET,
customRoutes: [
{
path: '/oauthstart/:slackUserId',
method: ['GET'],
handler: (req, res) => {
res.writeHead(200);
res.end(`Hello ${req.params.slackUserId}!`);
},
},
],
}); Which should return Collecting query strings from const app = new App({
token: process.env.SLACK_BOT_TOKEN,
signingSecret: process.env.SLACK_SIGNING_SECRET,
customRoutes: [
{
path: '/oauthstart',
method: ['GET'],
handler: (req, res) => {
// Gather parameters from the URL
let urlParams: URLSearchParams = new URLSearchParams();
const params = req.url.split("?");
if (params.length > 1) {
urlParams = new URLSearchParams(params[1]);
}
// Collect the `slackUserId` if it exists
const userId = urlParams.get("slackUserId");
res.writeHead(200);
res.end(`Hello ${userId ?? "world"}!`);
},
},
],
}); For more details on how these routes are handled, feel free to check out the docs on custom routes. And also, a huge shout out to @jeffbaldwinjr for handling the implementation of this! It's a really neat feature to be using! 🎉 👏 |
Description
When I try to setup a custom HTTP route (the built-in ones) this way:
And I try to reach the HTTP route - for instance with
http://my-bolt-app.com/oauthstart/U01T7MJ9RPY
, I get the following error:I tried to implement the same using query strings, but I get the same error. Am I doing something wrong or is it a bug? Thanks!
What type of issue is this? (place an
x
in one of the[ ]
)Requirements (place an
x
in each of the[ ]
)Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
package version:
node version:
OS version(s):
Steps to reproduce:
Expected result:
What you expected to happen
Actual result:
What actually happened
Attachments:
Logs, screenshots, screencast, sample project, funny gif, etc.
The text was updated successfully, but these errors were encountered: