livebud / bud

The Full-Stack Web Framework for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to debug routing problems?

IvanRibakov opened this issue · comments

Hi, I'm taking bud for a spin and it seems like I've hit a road block early on. I have created a new app using bud create and confirmed that default welcome page was displayed using bud run.

My next step was to add a simple static page like this:

// /view/index.svelte

<main>
  <p>Hello world</p>
</main>

However, now http://127.0.0.1:3000/ returns 404 page not found.

How can I proceed to debug this issue? I ran bud -L debug run, but that doesn't output anything when I reload the page. Is there some way to see/dump the routing table for the project?

I also checked the /bud/ folder in case there is some generated code for the routing but didn't find anything there either.

Any hints on what I might be doing wrong or how could I proceed with debugging this would be much appreciated.

Hey @IvanRibakov, thanks for trying Bud!

Right now you need to create a controller in order to generate the route. So you'd need something like:

// controller/controller.go

package controller

type Controller struct {}

func (c *Controller) Index() {}

There is an RFC for Static Views have a look and let me know what you think!

Hi @matthewmueller , thanks for the quick response. I must have misunderstood the documentation then - I got impression that static views are implemented in the way they are described in the docs with an existing RFC looking to possibly change that.

Adding controller with Index method indeed solved the 404 problem, but now I just get an empty page with the following DOM:

<body>
    <main class="svelte-dx1l65"></main>
    <div class="slotHeader svelte-dx1l65"></div>
    <div class="slotFooter svelte-dx1l65"></div>
</body>

Notice there is no <p>Hello world</p> inside the main. I'm sorry for asking such question as I'm pretty sure it's me doing something wrong here, but in the absence of any log messages or other debug tools I'm not sure how to debug my way out of this.

No worries, the documentation and examples are still a bit sparse. Debugging tools are still in their infancy, though bud --log=debug run may give you some answers.

Can you share your directory tree? That would help us debug this issue.