Closed devonpmack closed 2 years ago
This is supported, see HttpRegExp
https://deepkit-book.herokuapp.com/deepkit-book-english.html#_path_parameters
example
class Controller {
@http.GET('string/:text')
text(text: HttpRegExp<string, '[a-zA-Z]*'>) {
return [text];
}
@http.GET('number/:number')
number(number: HttpRegExp<number, '[0-9]*'>) {
return [number];
}
}
I made it possible to pass an actual RegExp object to HttpRegExp
in https://github.com/deepkit/deepkit-framework/commit/ba98832bc33662914145e3fb7654bd9a040d52e8
const pattern = /one|two/;
class Controller {
@http.GET('type/:type')
type(type: HttpRegExp<string, typeof pattern>) {
return [type];
}
}
Great! Thanks, I missed that.
Expected
GET
/three
would route to theother
methodGET
/two
routes to thepage
methodActual
Validation error because
three
doesn't matchone|two