Skip to content

Conversation

@tuxalp
Copy link
Collaborator

@tuxalp tuxalp commented Jan 27, 2026

This PR introduces:

  • a Refactoring for the servers
  • dispatching ability for OJP1 and OJP2 (server.py)

Aim of the refactoring:
The aim of the refactoring is to

  • reduce the amount of code redundancy
  • improve readability of the code (e.g. not using extensive if/else code blocks for error handling)
  • improve and centralize error handling
  • allow separation of code for OJP1 and OJP2

Dispatching:

  • server.py now dispatches TripFareRequests to according services (api.ojp1.OjpFareServiceOjp1 and/or api.ojp1.OjpFareServiceOjp2), depending on the version flag ("1.0" or "2.0") in the payload.
  • Parsing of the version number is implemented in OjpVersionParser.py.
  • server_ojp2.py serves ojp2 requests only (like before)
  • server_ojp1.py serves ojp1 requests only (new)
  • server implementations delegate requests to api.ojp1.OjpFareServiceOjp1 and/or api.ojp1.OjpFareServiceOjp2

The api package:

  • the idea of the new "api" package is to introduce an API layer (presentation layer), responsible for the implementation of the OjpFare API.
  • includes Error Handling, OJP Version Parsing, services for ojp1 and ojp2
  • try to separate api code from other code, e.g. the code responsible for the NOVA client, mapping code etc.

Error handling:

  • api.errors: Implementation of Exceptions (e.g. InternalServerError) that can be handled by the ErrorHandler
  • ErrorHandler.py:
  • ErrorHandler: handles an ApiError exception and creates an according Response using a ErrorResponseContentProvider
  • ErrorResponseContentProvider: Creates error response content from a message (depending on OJP version)

@tuxalp tuxalp requested a review from ue71603 January 30, 2026 08:01
@ue71603
Copy link
Collaborator

ue71603 commented Jan 30, 2026

Pls provide details about the refactoring in the description

@ue71603
Copy link
Collaborator

ue71603 commented Jan 30, 2026

@tuxalp Ich möchte gerne, dass Du in der Description zusammenfasst, was das Refactoring macht. Ich würde auch noch warten, bis wir auch das Problem mit Europaplatz gelöst haben. Dann werde ich reviewen.

@tuxalp tuxalp marked this pull request as draft February 3, 2026 12:09
@tuxalp tuxalp changed the title SKIPLUS-1012: refactor servers. SKIPLUS-1012: refactor servers and introduce dispatching Feb 3, 2026
@tuxalp tuxalp changed the title SKIPLUS-1012: refactor servers and introduce dispatching SKIPLUS-1012: refactor servers and introduce dispatching server Feb 3, 2026
@tuxalp tuxalp marked this pull request as ready for review February 3, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants