Rest controller route naming issue

4 views
Skip to first unread message

Reinier van Vliet

unread,
Nov 4, 2013, 5:22:03 PM11/4/13
to golang...@googlegroups.com
Hi,

In your example_webapp you have a ThingsController which results in a route like:  localhost:9090/things

However, I noticed that when I was adapting your example to the following name: NewsItemController
that there was no route at all anymore which would respond. I tried:  localhost:9090/newsitem as well as localhost:9090/news but both didn't respond.

I'm just starting with GO development so I presume I'm doing something wrong, although it was unclear to me what exactly.

Thanks

Reinier

Mat Ryer

unread,
Nov 5, 2013, 11:17:49 AM11/5/13
to golang...@googlegroups.com

The best way to see what routes have been mapped is to log the Handler itself.

Put this after your mapping code:

  log.Println(“Try some of these routes:")

  log.Printf("%s", goweb.DefaultHttpHandler())

That should make it clear what has been mapped.

Alternatively, if you specify a `Path() string` method on your controller, it will use that to decide which path to map to.

Mat

Reinier van Vliet

unread,
Nov 5, 2013, 4:22:03 PM11/5/13
to golang...@googlegroups.com
Great! 

Turned out that the NewsItemController mapped to: localhost:9090:/news-item/
Good to know that the path method can optionally tweak the mapping default.

thanks

Reinier

Op dinsdag 5 november 2013 17:17:49 UTC+1 schreef Mat Ryer:
Reply all
Reply to author
Forward
0 new messages