Skip to content
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

How to access Express request object from within app.view method #1110

Closed
4 of 10 tasks
Evilweed opened this issue Sep 8, 2021 · 4 comments · Fixed by #1177
Closed
4 of 10 tasks

How to access Express request object from within app.view method #1110

Evilweed opened this issue Sep 8, 2021 · 4 comments · Fixed by #1177
Assignees
Labels
duplicate An issue for the same purpose already exists, and a link is in the comments enhancement M-T: A feature request for new functionality question M-T: User needs support to use the project
Milestone

Comments

@Evilweed
Copy link

Evilweed commented Sep 8, 2021

Description

I've added middleware to Express server that creates Tracing span and then pushes it into request object that is being passed between express middleware and in normal express server is also available later.

With bolt.js i only have access to ack, payload, body, view, client, context for example in app.view method.

How can i access "request" object from within app.view?
Or how can i pass some data from express server middleware to bolt.js app.view?

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

export const distributedTracingMiddleware = function addDistributedTracing(
	req,
	res,
	next
) {
	// Creating our trace span using trace span context from incoming request
	const tracingContextFromRequest = tracer.extract('http_headers', req.headers)
	const span = tracer.startSpan(req.path, {
		childOf: tracingContextFromRequest,
	})

	// 👋 Adding trace span to the request object for any other Express.js handler to use the span
	Object.assign(req, { span })

	})
			this.app = new App({
				signingSecret: Secrets.slackSigningSecret,
				token: Secrets.slackToken,
				logLevel: LogLevel.DEBUG,
				endpoints: '/',
				receiver: this.expressReceiver,
			})

// 👋 Adding middleware to express server
this.expressReceiver.app.all('*', distributedTracingMiddleware)
	app.view<ViewSubmitActionExtended>(
		ACTIONS.BUG_REPORT_CREATE_TICKET,
		async ({ ack, payload, body, view, client, context }) => {
                        // 👋 Here i would like to access Express.js "request" object or somehow pass some data from express middleware
                       console.log(request.span)
        }))
@gitwave gitwave bot added the untriaged label Sep 8, 2021
@seratch seratch added enhancement M-T: A feature request for new functionality question M-T: User needs support to use the project and removed untriaged labels Sep 8, 2021
@seratch seratch added this to the 3.8.0 milestone Sep 8, 2021
@seratch
Copy link
Member

seratch commented Sep 8, 2021

Hi @Evilweed, thanks for writing in!

We got a similar question #1109 on the same day. Please refer to my comment in the issue: #1109 (comment)

As mentioned in the comment, unfortunately, there is no way to access HTTP request data at this moment but we are planning to add a custom properties to context object in future versions.

@srajiang
Copy link
Member

srajiang commented Sep 13, 2021

Hi @Evilweed - Was the above helpful? If so feel free to close this issue and follow along on the main thread on #1109. I will revisit in a few days and close this up if we don't hear back from you.

@Evilweed
Copy link
Author

@seratch @srajiang shouldn't we close this issue only if you actually implement the feature in PR, merge it and release a change that allows us to access the extra data in context passed from request middleware? This feature does not exist yet.

@srajiang
Copy link
Member

srajiang commented Sep 14, 2021

Hi @Evilweed - Yep you're right about that - this issue can remain open while the feature is not implemented / on the roadmap. Apologies, I'm new on the team and to our triage workflows!

@srajiang srajiang added the duplicate An issue for the same purpose already exists, and a link is in the comments label Sep 14, 2021
@seratch seratch self-assigned this Oct 26, 2021
seratch added a commit to seratch/bolt-js that referenced this issue Oct 26, 2021
…ies in ReceiverEvent and Context objects
seratch added a commit that referenced this issue Oct 28, 2021
… Context objets (#1177)

* Fix #759 #1109 #1110 by adding custom properties in ReceiverEvent and Context objects
* Add AWS receiver implementation
* Fix bugs in SocketModeReceiver and add more tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate An issue for the same purpose already exists, and a link is in the comments enhancement M-T: A feature request for new functionality question M-T: User needs support to use the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants