[Attempto] A RESTful api for AceWiki

Kaarel Kaljurand kaljurand at gmail.com
Thu Dec 8 15:16:46 CET 2011


Hi,

On Wed, Dec 7, 2011 at 12:53, Changyuan Yu <reivzy at gmail.com> wrote:
> Before show how the RESTful api works, I want to make some explanation
> about the changes of the code.

I would also like to say that this is very nice work! Developing
AceWiki into a webservice with potentially many UIs is definitely the
way to go. E.g. I would like to have a Unix commandline client that
lets me quickly push into AceWiki sentences that I know are
syntactically correct (and that therefore need no predictive editing),
and I'd like to have a mobile client whose UI is optimized for
querying (e.g. via speech input) rather than general AceWiki editing.

> 1. Using APESocket instead of APELocal to call APE. On my
> system(Gentoo amd64), every time upgrade swi-prolog, I must
> reconfigure tomcat to make JPL work(libjpl.so location changes). And
> if I compile swi-prolog as static binary and library, then tomcat will
> crash. Current code initialize APESocket with fix host and port(port
> 2766 on localhost), so an instance of ape.exe must run in socket
> server mode to make AceWiki work.

Ideally this should be configurable in war/WEB-INF/web.xml. I think I
would personally also use APESocket or APEWebservice and switch to
APELocal only if it brings any major performance benefits (but I think
it's not that much faster than APESocket).

I think we should implement this configurability in the master-branch
of AceWiki.

> 2. Make the war be able to deployed in an OSGi container
> (apache-karaf), compare to tomcat, apache-karaf is easier to use. I
> can start, stop and re-deploy the war in karaf shell. To achieve this
> goal, I modify the build.xml to add some information into
> META-INF/MANIFEST.MF during build process.
> [...]
> 4. deploy the war into any servlet container(tomcat, jetty,
> apache-karaf etc), no need of special settings.

Can you post some instructions on how to best launch the apache-karaf?

I tried your fork with Jetty Runner and everything worked apart from
the REST API, I kept getting the 404-error when using: curl
"localhost:9077/acewiki/api/".

> curl -X POST localhost:8181/acewiki/api/0 -d '{"statement":""}'
>
> will return a list of possible words to start a sentence, the return
> [...]
>
> And for get next possible word after "an apple", using below command:
> curl -X POST localhost:8181/acewiki/api/0 -d '{"statement":"an apple"}'
> [...]
> Also, for test whether a sentence(or part of sentence) is valid,
> curl -X POST localhost:8181/acewiki/api/0 -d '{"statement":"a apple not fruit"}'

I think here it would be nice to have (alternatively) a GET-interface
without any JSON in the input, i.e.

GET acewiki/api/0/statement
GET acewiki/api/0/statement/an+apple

or

GET acewiki/api?statement=an+apple
GET acewiki/api?statement=an+apple+not+fruit


Best regards,
Kaarel


More information about the attempto mailing list