feat(ocpp): 添加对WebSocket子协议的支持和缺失参数检查
This commit is contained in:
@@ -85,8 +85,12 @@ app.get(
|
||||
'/ocpp/:chargePointId',
|
||||
upgradeWebSocket((c) => {
|
||||
const chargePointId = c.req.param('chargePointId')
|
||||
if (!chargePointId) {
|
||||
throw new Error('Missing chargePointId route param')
|
||||
}
|
||||
const connInfo = getConnInfo(c)
|
||||
return createOcppHandler(chargePointId, connInfo.remote.address)
|
||||
const requestedProtocol = c.req.header('sec-websocket-protocol')
|
||||
return createOcppHandler(chargePointId, connInfo.remote.address, requestedProtocol)
|
||||
}),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user