fix: add cors and allowed_origins to server standalone parameters #2177
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe Your Changes
This pull request refactors the server setup and configuration process in the
engine/main.cc
file by introducing aServerParams
struct and aSetupServer
function. Additionally, it updates command-line argument handling and help text to reflect these changes.Key changes include:
Refactoring server setup:
ServerParams
struct to encapsulate server parameters such asserver_host
,server_port
,api_keys
,cors
, andallowed_origins
. ([engine/main.ccL63-R102](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-8651ef9f256f38a44086c44bf92b235f3486b0b555bb4c56632e9a54d01f40c5L63-R102)
)SetupServer
function to handle server configuration updates based on theServerParams
struct. ([engine/main.ccL63-R102](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-8651ef9f256f38a44086c44bf92b235f3486b0b555bb4c56632e9a54d01f40c5L63-R102)
)RunServer
function to no longer accepthost
andport
parameters, as these are now handled bySetupServer
. ([[1]](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-8651ef9f256f38a44086c44bf92b235f3486b0b555bb4c56632e9a54d01f40c5L84-L100)
,[[2]](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-8651ef9f256f38a44086c44bf92b235f3486b0b555bb4c56632e9a54d01f40c5L571-R600)
)Updating command-line argument handling:
ServerParams
struct instead of individual variables. ([[1]](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-8651ef9f256f38a44086c44bf92b235f3486b0b555bb4c56632e9a54d01f40c5L464-R486)
,[[2]](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-8651ef9f256f38a44086c44bf92b235f3486b0b555bb4c56632e9a54d01f40c5L480-R512)
,[[3]](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-8651ef9f256f38a44086c44bf92b235f3486b0b555bb4c56632e9a54d01f40c5L502-R542)
)--cors
and--allowed_origins
. ([[1]](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-8651ef9f256f38a44086c44bf92b235f3486b0b555bb4c56632e9a54d01f40c5L480-R512)
,[[2]](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-8651ef9f256f38a44086c44bf92b235f3486b0b555bb4c56632e9a54d01f40c5L502-R542)
)Improving help text:
--cors
argument and renamed--api_configs
to--api_keys
. ([engine/main.ccL437-R459](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-8651ef9f256f38a44086c44bf92b235f3486b0b555bb4c56632e9a54d01f40c5L437-R459)
)Minor changes:
AreUrlPathsEqual
function inengine/utils/string_utils.h
. ([engine/utils/string_utils.hR231](https://github.com/menloresearch/cortex.cpp/pull/2177/files#diff-7b4479b6eba1e98453848526c53fda755811ed5017fa743307d6ed174a0ee580R231)
)Fixes Issues
Self Checklist