RejectedSoftware Forums

Sign up

Row to debug router matches

Hello !

I have some functions that are annotated with @path and I'm getting:
--------------- http://127.0.0.1:8088/customer/delete/id/55
404 - Not Found

Not Found

Internal error information:
Not routes match path '/customer/delete/id/55'

How can I debug it ?

I added this to web.d:

void registerWebInterface(C : Object, MethodStyle method_style = MethodStyle.lowerUnderscored)(URLRouter router, C instance, WebInterfaceSettings settings = null)
{

import std.array : endsWith;
import std.traits;

if (!settings) settings = new WebInterfaceSettings;

foreach (M; __traits(allMembers, C)) {
	/*static if (isInstanceOf!(SessionVar, __traits(getMember, instance, M))) {
		__traits(getMember, instance, M).m_getContext = toDelegate({ return s_requestContext; });
	}*/
	static if (!is(typeof(__traits(getMember, Object, M)))) { // exclude Object's default methods and field
		foreach (overload; MemberFunctionsTuple!(C, M)) {
			alias RT = ReturnType!overload;
			enum minfo = extractHTTPMethodAndName!overload();
			enum url = minfo.hadPathUDA ? minfo.url : adjustMethodStyle(minfo.url, method_style);
			
			version(debug_router) { ///////////to help debug
				import vibe.core.log;
				logInfo("registerWebInterface: %s", url);
			} //////////////////<<<<<<<

			static if (is(RT == class) || is(RT == interface)) {

The I get this output at compile time:

registerWebInterface: /
registerWebInterface: /list/:entity
registerWebInterface: user
registerWebInterface: /user/:userid
registerWebInterface: /user/:email/email
registerWebInterface: /user/:user
id/delete
registerWebInterface: /user/:email/email/delete
registerWebInterface: /user/delete/:fieldname/:fieldvalue
registerWebInterface: /user/:fieldname/:fieldvalue
registerWebInterface: /customer/list/:limit
registerWebInterface: /customer/delete/:fieldname/:fieldvalue
registerWebInterface: customer
registerWebInterface: customer
registerWebInterface: /customer/:fieldname/:fieldvalue

Any clue on how to debug it ?

Re: Row to debug router matches

I just discover that I do not need to add anything to web.d as I did, I can achieve better information setting the debug level at runtime on the application entry point.

setLogLevel(LogLevel.trace);

With that I could see that my url call is added to the "DELETE" method but I was trying to call it using "GET".

Cheers !

Re: Row to debug router matches

It seems that vibed do not accept any form of method overwrite like: "X-HTTP-Method-Override: DELETE" or passing any query string parameter for example like this:

http://www.restfm.com/manual_v1/method-override

I'm missing something here ?

Cheers !

Re: Row to debug router matches

Am 20.10.2014 23:31, schrieb Domingo:

It seems that vibed do not accept any form of method overwrite like: "X-HTTP-Method-Override: DELETE" or passing any query string parameter for example like this:

http://www.restfm.com/manual_v1/method-override

I'm missing something here ?

Cheers !

"X-HTTP-Method-Override" is currently not implemented - if you have some
time to add a ticket on the issue tracker, that would be great, because
I'll have forgotten this again for sure before getting to implement it!

For now, you could either just tag the method with
@method(HTTPMethod.POST) (or GET), or add an additional overload that
uses POST instead of DELETE and let that call the original method, so
that both are available.