-
Posts
95 -
Joined
-
Last visited
-
Days Won
2
Everything posted by thomasaull
-
@calago can you provide your "routes.php" aswell as the file with the endpoint function you're calling in your route?
-
Hi @louisstephens, thanks for the kind words! I remember that I had the exact same problem as you once, but I can't remember what the problem or the solution actually was. Afaik it was not an issue with the module itself but with how ProcessWire handles image paths. I think I did some digging by creating a new template and return the image path there — maybe you could try that and let me know about the result. Also you could try to experiment mit $page->of (output formatting). This might have an effect on that matter aswell.
-
@lemgrago I think at the moment the module only supports a single depth of grouping. I did a quick check and it doesn't work for me either. If it helps you can always declare your routes like: 'firstlevel/secondlevel' => [ ['GET', 'endpoint', Example::class, 'test'], ], 'firstlevel/another-secondlevel' => [ ['GET', 'endpoint', Example::class, 'test'], ], I might add multiple nested groups in the future
-
Hi @joshua, thanks for finding it useful ? Personally I mostly use the RestAPI Module to gather data from multiple sources for a single endpoint. For example a blogpost might have info about the post itself, but also might pull in additional data about the author which might live on a completely different page. However I can think of usecases like yours where bascially a dump of all the data might be useful. Unfortunately there is no built in functionality for this in the module. You could check out http://modules.processwire.com/modules/pages2-json/ which does a similar thing or the GraphQL Module (http://modules.processwire.com/modules/process-graph-ql/) also goes in this direction.
-
Recently a user of this module had the problem that some multi-language fields weren't working correctly.kno After some investigation I discovered, that the hook this module uses (it's a "before ProcessPageView::execute") kicks in to early for the multi-language plugins to be ready. Does anyone knows of a hook, which can do something similar (basically take over the default routing of ProcessWire) while still have the other modules loaded? One alternative approach for this specific problem would be to not trigger the module via a hook but with an own template and page like the old RestApiProfile did. A couple of benefits would come for free aswell (these are my assumptions, not tested yet): ProCache should work without any workarounds Multi-Language works Websites in subdirectories (if working in ProcessWire in general) should work site profile export would work if the /api folder lives in /templates by default Any potential downsides I'm not seeing yet? Thoughts?
-
@dragan Can you please check your php error log too?
-
@thibaultvdb I need to check this, since I think (when I remember it properly) I put this option in specifically for this use-case. If you want to fiddle around try making it work or you know/want to figure out how ProcessWire does this automatically feel free ? Otherwise I can't really make any promise when I'm going to be able to look into this
-
@thibaultvdb In the module settings there is an input for "API Endpoint" — can you try to change the value there to "localhost/api" and report back if this works for you?
-
@thibaultvdb If what @flydev says is the case and you're trying to access your website inside a subdirectory you could also try to adjust the path for the api in the module settings. Maybe it'll work ?
-
@thibaultvdb It's a bit difficult to help from here. One thing you could try is to go through the code in Router.php and return or exit early to find out until where the code runs. The main functions are "go()" and "handle()". Another idea is to compare php settings between your hosted and local environment with "phpinfo()". If you can isolate the issue it's much easier to help.
-
@pmichaelis I'm gonna ask anyway: Why? ? Seems like a weird server config, but I could add this to the variables the module checks by default.
-
@pmichaelis If the error is thrown in line 131 it's likeley there is an error with the JWT Authorization. Maybe the Token you're submitting is not valid, maybe something else. Hard to tell with the little information you provided. Oh, just noticed you already mentioned the JWT Auth… ? Probably the error is produced in those 4 lines: $secret = wire('modules')->RestApi->jwtSecret; $token = str_replace('Bearer', '', $authHeader); $token = trim($token); $decoded = JWT::decode($token, wire('modules')->RestApi->jwtSecret, array('HS256')); if the secret is in your config and you didn't change it, I'd check if the token gets transmitted properly with the request.
-
@siilak I think all you need to do is to add your route in Routes.php: $routes = [ ['PUT', 'user', User::class, 'addUser'], ]; And have some functionality for adding your data in your 'addUser' Function. Let me know, if it works!
-
@Sebi@pmichaelis Think I'm going to include @pmichaelis since it does not required additional configuration (actually before I used the RestApi Module with NGINX it was using apache_request_headers anyway)
-
@flydev Thanks for your PR. I'm going to investigate (feel free to remind me, if you don't hear back)! One concern though, do you think it's a good practice to send the password on every request? In this case you'd have to store the password somewhere in your frontend, which I think is security bad practise. Maybe other people do have an opinion about that?
-
@pmichaelis Is vagrant using an apache or nginx server? Can you check where the authorization header is contained in your case (apache_request_headers or $_SERVER)? And what version of php are you using?
-
@dragan Yes, it basically only sends a POST Request to a webhook url without any further information. So your assumption is correct ? In my case the CI Pipeline does a static build of the website and deploys it on the server. What happens in your build pipeline is totally up to you though. You could also do a request from your pipeline to your API to gather further information if needed. The trigger does not become active for system templates and pages which are not public, this is the related code: // do nothing for system pages: if ($page->template->flags === Template::flagSystem) return; // do nothing if page is not public if (!$page->isPublic) return;
-
@flydev I adjusted the Regex Pattern for the endpoint url to allow numbers too: https://github.com/thomasaull/RestApi/commit/f2e851faf4b89449bca496d6bea20ee85dc0f6ee Please update the module to 0.0.6 for this to become active
-
It might be a good idea to make this configurable, so the user can choose between a webhook or select a page to act as the api endpoint. You wanna provide a PR @eelkenet? I'm a bit short of time currently.
-
I created a little helper module to trigger a CI pipeline when your website has been changed. It's quite simple and works like this: As soon as you save a page the module sets a Boolean via a pages save after hook. Once a day via LazyCron the module checks if the Boolean is set and sends a POST Request to a configurable Webhook URL. Some ideas to extend this: make request type configurable (GET, POST) make the module trigger at a specified time (probably only possible with a server cronjob) trigger manually Anything else? If there's interest, I might put in some more functionality. Let me know what you're interested in. Until then, maybe it is useful for a couple of people ? Github Repo: https://github.com/thomasaull/CiTrigger
-
@gottberg @flydev I created a small helper class for dealing with responsive images: <?php namespace ProcessWire; class Image { public static function get ($image, $widths = [400, 800, 1200]) { $response = new \StdClass(); $response->focus = ["x" => $image->focus['left'], "y" => $image->focus['top']]; $response->urls = []; $response->description = $image->description; $response->name = $image->basename; $response->width = $image->width; $response->height = $image->height; foreach ($widths as $width) { $croppedImage = $image->width($width); $url = new \StdClass(); $url->url = $croppedImage->httpUrl; $url->width = $croppedImage->width; $url->height = $croppedImage->height; $url->ratio = $croppedImage->height / $croppedImage->width; array_push($response->urls, $url); } return $response; } } Usage: // $image is your ProcessWire PageImage return Image::get($image, [400, 800, 1200, 2000, 2500]);
-
@eelkenet I'm sorry, somehow I missed your post. Do you think there is any way I can support ProCache with the module itself? I could also use a page in the pagetree to deliver the endpoint instead of doing it with a Hook
-
@pwFoo What exactely do you mean by 1)? Mapping an endpoint to a PW Page is as easy as $page = wire('pages')->get(1042); in your endpoint function. Mapping an endpoint to a php file is the intendend behaviour of the module, check the example: https://github.com/thomasaull/RestApi/blob/master/apiTemplate/Example.php which get's mapped in the Routes.php: https://github.com/thomasaull/RestApi/blob/master/apiTemplate/Routes.php 2) That's basically the approach @LuisM used in his PR. I'm not sure if it's the best solution, check my comment on Github: https://github.com/thomasaull/RestApi/pull/1#issuecomment-450135767
-
Can't update my module in Modules Directory
thomasaull replied to thomasaull's topic in Module/Plugin Development
Oh dear! Thanks @BitPoet that's the solution ? I actually just missed to update the version in info.json… -
I tried to update the RestApi Module (http://modules.processwire.com/modules/rest-api/) from 0.0.3 to 0.0.4 without success. I updated everything on Github, published a new release over there and tried the following: wait couple of days for the module to update itself automatically input the new version number manually – after saving the version just stays the same Dunno if I'm doing something wrong or if it's broken?