How to register a service with springboot restful path?

i have a few apis which paths like ‘/goods/{goos_id}/detail’ in springboot projects with restful style.

According to documentation ,we could register routes with regexes in path , but it does not mention how to register a service’s path .

it works when i post a route register request with path ‘/goods/\d+/detail’
but it does not work on service request with the same path ,and get a error says ‘schema violation’

so i also tried urlencode the path according to documentation
, the request succeeds, but when i post reuqest like ‘’, i got a response with ‘no Route matched with those values’

What is the relation between routes’s host and services’s host ,
and which one takes effect when a api is called ?
I have tryed manys ways to set a path like ,and all do not work, is there someone know this ?


Could you give the output of your route when calling the admin api (:8001/routes)
It will help to see what kong stores as a route paths and other parameters.

Regarding the route register, how do you proceed ? declarative config or calling the admin api (with which client (curl, httpie…))

Having these information will help to figure out what could be wrong. From my experience, regex works well.

Regarding the question about the routes’host and services’s host, I would say that the routes’host is a optional criteria to match the route when a http request reaches kong (meaning that it checks the Host header which must be consistent with the route.definition). The services’s host is simply the upstream host (the host that will be targeted when forwarding the http request to the ‘real’ service)

Sorry ,there is a spoken mistake about routes’s host and services’s host。 Actually ,i want to know the difference between routes’s paths and services’s path .

By reading kong’s source code in router.lua , i found something useful ,and have resloved my problom:

if matched_route.strip_uri then  
     upstream_uri = upstream_base .. request_postfix
     upstream_uri = upstream_base .. sub(req_uri, 2, -1)

Kong’s document takes a lot of words to introduce router, upstream etc, but only service ,and how the strip_path parameter works . Finally, source code show that .

Thanks for your reply.

© 2018 Kong Inc.    Terms  •  Privacy  •  FAQ