NetTalk Central

Author Topic: Virtual directories  (Read 2316 times)

markster

  • Full Member
  • ***
  • Posts: 204
    • View Profile
    • Email
Virtual directories
« on: August 29, 2013, 01:36:52 PM »
I'm setting up my (upcoming) web app with an OAuth and REST API. The programmer who's helping me with upload/download code has recommended I use virtual directories as in IIS, for example: https:/www.somecompany.com/ouath/rest/addinvoice?ouath_token={token} , etc.

In NetTalk the directories created are based on the name entered in the Browse/Form, so I'm getting for example: https:/www.somecompany.com/addinvoice?ouath_token={token}. Is there a way to do virtual directories?

Thanks,

Mark

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: Virtual directories
« Reply #1 on: August 29, 2013, 03:53:45 PM »
G'day,

In the WebServerHandler you can see the whole incoming URL when submitted by a client. You can simply put your logic in either the "ProcessLink" or even the "_SendFile" embed points.

I use the _SendFile embed as this is where NetTalk sends the request when it doesn't recognise the URL as one of its internal pages.

Just parse p_Filename and then route to your appropriate code.

Oh, and its miles better than virtual directories via IIS!

Regards
Bill


kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Virtual directories
« Reply #2 on: September 01, 2013, 09:01:56 PM »
Hi Bill,

so in Marks example the API would still call

https:/www.somecompany.com/ouath/rest/addinvoice?ouath_token={token}

but in the _sendfile routine I would look for

https:/www.somecompany.com/ouath/rest/addinvoice

and send

https:/www.somecompany.com/addinvoice

instead?

Also Mark, how are you issuing tokens and doing all the OAuth validation etc? Did you write your own code or use an add-on?

Cheers,


Kev


bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: Virtual directories
« Reply #3 on: September 01, 2013, 09:47:23 PM »
Hi Kevin,

The client app would request say:

https:/www.somecompany.com/ouath/rest/addinvoice?ouath_token={token}

and p_Filename in _SendFile would show:

/ouath/rest/addinvoice?ouath_token={token}                  (roughly)


From here you could parse (using stringTheory or manually) p_filename since the directories are just a hierarchy that represents context, and sometimes key values.

Marks job will be much easier if he is using oAuth2 which is lovely compared to oAuth1. SkyDrive and Google use oAuth2. Dropbox has started to allow oAuth2 but alas Xero still hasn't and doesn't really appear to care.

If you were writing your own rest web server, then oAuth2 is definitely the way to go as SSL does all the annoying work for you.

Also, I think (and Bruce could correct me if i'm wrong) NetTalk ignores preceding folders names, so you'd want addinvoice to not also be used as a pagename, otherwise it will not get to _SendFile.

Regards
Bill

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Virtual directories
« Reply #4 on: September 02, 2013, 09:12:03 PM »
Thanks Bill.

markster

  • Full Member
  • ***
  • Posts: 204
    • View Profile
    • Email
Re: Virtual directories
« Reply #5 on: September 03, 2013, 09:33:25 AM »
Thanks for the input. I've been off a few days and am just reading these now. I am working on OAuth processing as part of an API for my web app, but as usual everything is taking longer than I thought. I'm working with another Clarion programmer who is conversant with that coding but not with NetTalk.

Mark