Comments (10)
@binarytrails
We have discussed this issue and the only solution we have found so far is:
- you need a customized version of http-parser with support of your custom HTTP methods. It is necessary because HTTP is processed by http-parser library, not by RESTinio. And http-parser just rejects all unknown HTTP methods. It means that you need a fork of http-parser with hardcoded new HTTP methods inside. It is not a complex task. This is my example of such fork;
- we can add a customization point to RESTinio. That point will allow using RESTinio with a customized version of http-parser. I've done a draft of that version of RESTinio. It can be found here (in 0.4.10-custom-methods-example branch). And here you can download a tarball with this draft and related libraries inside;
- customization of RESTinio for non-standard version of http-parser can look like in that example. Note fragments between lines 25-32, 35-66 and 141-146.
Maybe there are some other approaches to support custom HTTP-methods in RESTinio, but we don't discover them yet.
So if that approach is appropriate for you then we can go further and start working on the preparation of next release of RESTinio with ability to work with custom versions of http-parser. But note that support of those custom versions of http-parser is your responsibility, we won't support them (and my custom version of http-parser is just an experimental example).
from restinio.
It's not an easy question.
Can you provide the list of methods you need?
from restinio.
@eao197 LISTEN, STATS, SIGN, ENCRYPT those are the only ones I saw in our API that are not already defined in the http_method_t
like SUBSCRIBE,UNSUBSCRIBE.
Thank you so much!
from restinio.
I've got your point. As I can see the usage of non-standard HTTP-method is not widespread, but it is not uncommon too. So it will be good to have the ability to handle non-standard HTTP-methods in RESTinio.
But I don't like the idea of integrating all non-standard methods into RESTinio's implementation. I think there should be a way to allow a user to extend the list of HTTP-method by himself/herself without modifying RESTinio's code.
We'll discuss that issue inside our team and reply to you ASAP.
from restinio.
@eao197 Perfect, I'll be waiting. I agree that they are not standard HTTP methods but the aim is to keep the new RESTful API backward compatible. Tell me if there is anything I can do.
from restinio.
We've done some discussion, and it seems that there is no simple way to add support for custom HTTP-method to RESTinio. There is a need for some experiments. But we'll have no time for that in the several next days because we're now busy with rolling out a new release of another our project. So I hope we can return to that issue at the end of the week.
from restinio.
@eao197 if you can suggest me ways of trying to implement it following RESTinio design, I can make a PR! Otherwise, looking forward to your experiments! I would say the backward compatibility of our proxies is the only critical thing due to their omnipresent usage in the jami.net project. Cheers,,
from restinio.
I went through the nodejs/http_parser
fork, RESTinio custom_http_methods
example and it looks absolutely great!
We really appreciate the efforts that your team made for the backward compatibility of our non-standard HTTP methods. Let's move forward and have it at the next RESTinio release.
I will embbed and test a forked http_parser
with the RESTinio integration into the OpenDHT PR 403 asap.
Sincerely,
Seva
from restinio.
We decided not to keep compatibility with restinio-0.4 because even with some tricks new definitions of http_method_t::http_get
, http_method_t::http_put
and so on won't be complete replacement for the old ones. Because of that we started restinio-0.5 where there is no http_method_t
at all. Instead there is http_method_id_t
class. There are also old http_method_get()
, http_method_put()
, http_method_post()
and other functions those return instances of http_method_id_t
.
In restinio-0.5 the example of custom HTTP method support will look like that. Please note the following changes:
- an instance of
http_method_id_t
requires an integer ID of HTTP method and a pointer to string name of the method (that pointer should outlive thehttp_method_id_t
instance); - only one
from_nodejs
method should be defined incustom_http_methods_t
; - name
http_methods_mapper_t
should be used intraits_t
.
The second beta version of restinio-0.5 is available from GitHub or new restinio repository on BitBucket. You can try it, it seems to be almost ready to be released as a stable version 0.5.0. We have to update restinio's documentation so the official release is expected on next week. But you can use restinio-0.5 right now.
from restinio.
Seems very reasonable besides, it is not a big change in the code;
I really like your example on the Custom HTTP methods.
Thank you for your work!
Sincerely,
Seva
from restinio.
Related Issues (20)
- Compilation of express router tests fails on VC++ 19 (VisualStudio 2022) HOT 1
- HTTPS not working
- <algorithm> isn't included in easy_parser.hpp
- Any chance std::fopen() call can be changed to std::fopen_s()? HOT 14
- New overload for sendfile and std::filesystem::path?
- CMake configure fails when using boost asio via find HOT 9
- vcpkg should have a variant with RESTinio+Boost.Asio HOT 1
- There should be operator<< for http_status_code_t
- static_if_impl has to be replaced with if constexpr
- There is no such type as generic_request_handler_t
- build system regression: RESTINIO_USE_EXTERNAL_SOBJECTIZER no longer available HOT 3
- allow using catch2 from system HOT 8
- Slow compilation HOT 2
- HTTP/2 and HTTP/3 HOT 1
- Is ninja supported? HOT 2
- Do not use SO_REUSEADDR on Window by default
- Question: How to get http_server_t<> address HOT 2
- display webpage of directory listing HOT 1
- Many tests fail: failed to start server on 127.0.0.1:8086: bind: Address already in use HOT 1
- Fails to find system Catch2: include could not find requested file: Catch HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from restinio.