lorenzodonini / ocpp-go

Open Charge Point Protocol implementation in Go
MIT License
275 stars 126 forks source link

Fix the charge point ID #73

Closed michaelbeaumont closed 3 years ago

michaelbeaumont commented 3 years ago

This could be construed as a breaking change if users depend on the existing behavior but it's also a bug.

utsavanand2 commented 3 years ago

@michaelbeaumont I would suggest adding something like:

id := strings.TrimLeft(url.Path, "/")

This will make sure that we don't get the / in front of every charging station ID, makes it easier to parse the ID into an int if necessary.

michaelbeaumont commented 3 years ago

Base has the same behavior in the simple case of /CPID. But TrimLeft only removes one leading /, so if my listenPath is /ocpp then my ID will end up ocpp/CPID. With Base I get CPID, which is the ID as defined by the spec. By the way, nothing guarantees charge point IDs are integers.

lorenzodonini commented 3 years ago

This could be construed as a breaking change if users depend on the existing behavior but it's also a bug.

Indeed a breaking change 😅 I'm just wondering: is there any use case, in which CSMS operators would want the "full" path to be returned, instead of just the ID of the charging station?

michaelbeaumont commented 3 years ago

I don't think so. Of course, only if the path differs, but... the listenPath is fixed per server.

michaelbeaumont commented 3 years ago

And if they do, it shouldn't be available as the "ID" since that has a defined meaning.