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

Implement HTTP API #3599

Closed
wants to merge 2 commits into from
Closed

Conversation

TracerDS
Copy link
Contributor

This PR will allow you to fetch information from the server using the HTTP API.
I want it to work exactly like discord api (token, gateways, etc.)

@Fernando-A-Rocha
Copy link
Contributor

Beautiful initiative. I see you want to implement getting players & max player count for starters. That's good!

@Fernando-A-Rocha
Copy link
Contributor

What about HTTPS? And securing the api with an api key optionally?

@TracerDS
Copy link
Contributor Author

Beautiful initiative. I see you want to implement getting players & max player count for starters. That's good!

I want to implement every function + maybe more 😉

@TracerDS
Copy link
Contributor Author

What about HTTPS? And securing the api with an api key optionally?

HTTPS is out of control of this PR.
API depends on the server itself to maintain secure connection.
If the server has https handshake, so does api.

Hmm, api key might be generated via mta server. I'll keep that in mind when everything is done

@Fernando-A-Rocha
Copy link
Contributor

Beautiful initiative. I see you want to implement getting players & max player count for starters. That's good!

I want to implement every function + maybe more 😉

Will this API feature be enabled by default? Possibly through a MTAserver.conf setting.

@TracerDS
Copy link
Contributor Author

Beautiful initiative. I see you want to implement getting players & max player count for starters. That's good!

I want to implement every function + maybe more 😉

Will this API feature be enabled by default? Possibly through a MTAserver.conf setting.

probably, yes

@CrosRoad95
Copy link

Add at least some option to create custom api, mark old approach as outdated, change ehs lib to something more modern. Otherwise this feature will be underutilized

@TracerDS
Copy link
Contributor Author

Add at least some option to create custom api

It will be added later

mark old approach as outdated

What old approach? exports?

change ehs lib to something more modern.

Other PR maybe

@jlillis
Copy link

jlillis commented Jul 22, 2024

It is already possible to implement your own HTTP API in Lua resources.

@TracerDS
Copy link
Contributor Author

It is already possible to implement your own HTTP API in Lua resources.

Yes but its very limited. With this approach its very flexible and it is possible to easily adjust it to your needs without needing any resources.
You also have one endpoint only. With this change you can decide which endpoint you want to use

@Dutchman101
Copy link
Member

How exactly does this feature use EHS?
The version of EHS (and EHS itself..) in MTA is ancient, from like 15 years ago, it's actually due to be replaced should someone be willing to.

Aren't there any implications of using an ancient implementation again, but for something else? It's already causing a ton of issues in its utilization for MTA's internal HTTP server.

@TracerDS
Copy link
Contributor Author

TracerDS commented Jul 22, 2024

How exactly does this feature use EHS? The version of EHS (and EHS itself..) in MTA is ancient, from like 15 years ago, it's actually due to be replaced should someone be willing to.

Aren't there any implications of using an ancient implementation again, but for something else? It's already causing a ton of issues in its utilization for MTA's internal HTTP server.

It only utilises EHS to register an endpoint. Everything else is handled by the mta code

@jlillis
Copy link

jlillis commented Jul 22, 2024

With this approach its very flexible and it is possible to easily adjust it to your needs without needing any resources.

The highest level of adjustment/customization options will come from it being implemented in Lua. There has been a general trend of servers re-implementing hardcoded features (the chatbox, F11 map, etc) in Lua for this reason.

You also have one endpoint only. With this change you can decide which endpoint you want to use

Not ideal, but I think that is an improvement that can be made to the current scheme.

@TracerDS
Copy link
Contributor Author

TracerDS commented Jul 22, 2024

With this approach its very flexible and it is possible to easily adjust it to your needs without needing any resources.

The highest level of adjustment/customization options will come from it being implemented in Lua. There has been a general trend of servers re-implementing hardcoded features (the chatbox, F11 map, etc) in Lua for this reason.

You also have one endpoint only. With this change you can decide which endpoint you want to use

Not ideal, but I think that is an improvement that can be made to the current scheme.

there is no point in having a lua resource just for that.
Lua is very limited and, comparing to this solution, slower.
Just because it can be done in Lua doesnt mean it have to be done in Lua.
Hell, we can accept this change and disable the api endpoint but then you'd be stuck with forced endpoint.

@CrosRoad95
Copy link

In my opinion, http server should be removed from server and instead separete application should be used to serve file and all http code should be removed from mta. Most hosting novadays offer separete "fast download" server anyway.
If you want to interface with your server from outside then use socket module, create new one that expose http api but this will not be part of mta.
I already had showned in past how easy it is to abuse http server

Server/mods/deathmatch/logic/CHTTPD.cpp Show resolved Hide resolved
vendor/ehs/httpresponse.h Outdated Show resolved Hide resolved
Server/mods/deathmatch/logic/CAPI.cpp Show resolved Hide resolved
@tederis tederis added the enhancement New feature or request label Jul 25, 2024
@Xenius97
Copy link
Contributor

Xenius97 commented Jul 31, 2024

What if NodeJS were implemented on the server side? When integrated into MTA, it could be suitable for many things, including this.
Currently, we have developed our own preprocessor/backend based on a similar principle, with a NodeJS/Deno backend. In my opinion, Lua 5.1 isn’t very fast or efficient for such tasks, it's only adequate for basic operations and won’t handle more significant loads well.

@TracerDS
Copy link
Contributor Author

What if NodeJS were implemented on the server side? When integrated into MTA, it could be suitable for many things, including this. Currently, we have developed our own preprocessor/backend based on a similar principle, with a NodeJS/Deno backend. In my opinion, Lua 5.1 isn’t very fast or efficient for such tasks, it's only adequate for basic operations and won’t handle more significant loads well.

there is no reason to include nodejs into already bloated code.
Connecting to NodeJS server is doable via Sockets module.
But thats all if its about connecting somewhere.

@Fernando-A-Rocha
Copy link
Contributor

Im convinced that we have all we need with botder's newly added router features
https://wiki.multitheftauto.com/wiki/Resource_Web_Access#Router

Copy link
Contributor

This draft pull request is stale because it has been open for at least 90 days with no activity. Please continue on your draft pull request or it will be closed in 30 days automatically.

@github-actions github-actions bot added the stale Inactive for over 90 days, to be closed label Nov 24, 2024
@TracerDS
Copy link
Contributor Author

Im not interested in advancing this PR further anymore.
If someone wants to refresh it, feel free to do so.

@TracerDS TracerDS closed this Dec 23, 2024
@TracerDS TracerDS deleted the 220724_HTTP-API branch December 23, 2024 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale Inactive for over 90 days, to be closed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants