Issue with Root Path


#1

Maybe is a dumb question but I’m starting to play with Jets. I had a little experience with rails but right know I’m studying Lambda and Serverless.
So I created a new Jets project, and I’m trying to do a simple hello world with the application Controller.

class ApplicationController < Jets::Controller::Base

def hello
puts “Hola mundo”
@Content = “Hello World”
end
end

To make it work with the Application layout, I made a hello.html.erb file in views/application

<%= @Content %>

And the routes file is:

Jets.application.routes.draw do
  
  root "application#hello"

  # The jets/public#show controller can serve static utf8 content out of the public folder.
  # Note, as part of the deploy process Jets uploads files in the public folder to s3
  # and serves them out of s3 directly. S3 is well suited to serve static assets.
  # More info here: https://rubyonjets.com/docs/extras/assets-serving/
  any "*catchall", to: "jets/public#show"
end

With Jets Server, It appears to be working OK.

I can see the Hello World using the application.html.erb layout an the content from the controller.

But when I deploy to AWS:

  1. In API Gateway the only generated Resources are:
/
   /{catchall+}
    ANY

And the Invoke URL only shows:

{"message":"Missing Authentication Token"}

I could surpass this making a GET Resource in the root Resource

/
GET
   /{catchall+}
    ANY

But now. I Only see the index page used for the catchall.

I’m trying to understand what is the APy Gateway doing or what is wrong with my routes, but if I test the GET Resource on the web, It returns the correct body.

So, why I’m seeing different results between the Resource Test, and the jets servier (http://127.0.0.1:8888/) where I can see the hell world vs the Invoke URL?


#2

ApplicationController doesn’t currently create lambda functions. Considered it an abstract controller.

But may change this in the future for this situation so it more closely matches local behavior. The catch is anyone who currently has public methods in their ApplicationController will have brand new functions, which isn’t the end of the world and can be fixed by making the methods private.

Try creating a different controller that inherits from ApplicationController.


#3

Great, Thanks. That explains a lot.

Well, I will continue using a new controller.