osgi.enroute.bundles icon indicating copy to clipboard operation
osgi.enroute.bundles copied to clipboard

[REST] Display a message on primary endpoint

Open watta90 opened this issue 9 years ago • 4 comments

Hi,

How do you choose what to return when the primary endpoint is called on your REST api?

I would like to return a String when a user calls GET on /rest

I'm not able to find any documentation on how to achieve this.

watta90 avatar Oct 09 '16 18:10 watta90

This is currently not possible …

Kind regards,

Peter Kriens

On 9 okt. 2016, at 20:42, vatanbytyqi [email protected] wrote:

Hi,

How do you choose what to return when the primary endpoint is called on your REST api?

I would like to return a String when a user calls GET on /rest

I'm not able to find any documentation on how to achieve this.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/osgi/osgi.enroute.bundles/issues/68, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMPLuN9HhN3I0J7Tv8Jq4bxdHiU-DH0ks5qyTWTgaJpZM4KSExD.

pkriens avatar Oct 10 '16 08:10 pkriens

that was sad.. Do you know if someone is working on this so I can follow up on that? Currently I don't have the time to make a contribution my self at the moment, hopefully in a couple of months.

Regards Vatan

watta90 avatar Oct 10 '16 11:10 watta90

The source code is https://github.com/osgi/osgi.enroute.bundles/tree/master/osgi.enroute.rest.simple.provider https://github.com/osgi/osgi.enroute.bundles/tree/master/osgi.enroute.rest.simple.provider

Since this is so little code it should not be very hard to add this feature here https://github.com/osgi/osgi.enroute.bundles/blob/master/osgi.enroute.rest.simple.provider/src/osgi/enroute/rest/simple/provider/RestMapper.java#L227 https://github.com/osgi/osgi.enroute.bundles/blob/master/osgi.enroute.rest.simple.provider/src/osgi/enroute/rest/simple/provider/RestMapper.java#L227

You could use a function that has some magic name like get$ to map to the empty path.

That said, you could also switch to JAX-RS. The OSGi enRoute REST API is incredibly easy to use but was not designed to allow the implementation of all possible REST APIs. Its primary goal was to support calls from the Javascript code into the java OSGI code.

Kind regards,

Peter Kriens

On 10 okt. 2016, at 13:04, vatanbytyqi [email protected] wrote:

that was sad.. Do you know if someone is working on this so I can follow up on that? Currently I don't have the time to make a contribution my self at the moment, hopefully in a couple of months.

Regards Vatan

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/osgi/osgi.enroute.bundles/issues/68#issuecomment-252588294, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMPLjjMlucAmxeJ_bOEItIhNQdxioiRks5qyhu3gaJpZM4KSExD.

pkriens avatar Oct 10 '16 11:10 pkriens

I think the most natural system is to just use raw verbs get(), post(), etc. rather than a special path name like $. Is there any problem with this approach? It was straightforward to implement this way, pretty much just removed the checks and error messages and it works: #85

eliasvasylenko avatar Mar 24 '17 10:03 eliasvasylenko