Jump to content

REST API without any modules or frameworks (pure ProcessWire)


Jonathan Lahijani
 Share

Recommended Posts

I need to develop a RESTful API in ProcessWire.  While I haven't developed one before, I am fairly comfortable with the general idea.

There are separate PHP frameworks that specialize in this, as well as specific ProcessWire modules, however I want to do this purely with ProcessWire.  I haven't seen discussion on this, but my thinking is the necessary features are there to make this happen, which are:

Any thoughts on this or recommendations?

Link to comment
Share on other sites

About URL hooks

Not sure it has change but once happened to me that I couldn't do optional segments, example:

/get-images/{page}/{field}/

Request wouldn't reach if I tried to get to:

/get-images/{page}/

Then I think the concept of middleware is not present? So say you want to block unauthenticated calls, check CSRF, etc, you'd have to make that check on every route hook.

Probably AppApi is still the way to go, feature wise? Project seems very alive!

Edit: Just reading AppApi actually uses path hooks to bootstrap its endpoints.

  • Like 1
Link to comment
Share on other sites

6 hours ago, Jonathan Lahijani said:

I haven't seen discussion on this

There has been a lot of discussion here ? https://processwire.com/talk/topic/26792-headless-processwire-how-do-you-do-it/

4 hours ago, elabx said:

Not sure it has change but once happened to me that I couldn't do optional segments, example:

/get-images/{page}/{field}/

I think this should work:

/get-images(/{page})?(/{field})?/

? 

  • Like 2
Link to comment
Share on other sites

3 hours ago, bernhard said:

I saw that thread before I wrote this post, but I seemed to have missed the few references to using URL hooks.

Thinking this further, I should consider using AppApi first before trying to roll my own solution.

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...