Where to get lost in specifications with Spark routing

It's also about spark routing. It's a small amount, so I have to put it together soon.

Routing when a world card is specified

If you set the path "/ sample / *", it will match the following URL.

/sample/
/sample/hello
/sample/hello/
/sample/hello/*

It does not match below.

/sample

Request parameters when using before, after, afterAfter

When using the path parameter, it is necessary to set the matching in filter as well.

Bad sauce

python


public static void main(String[] args) {

  before((request, response) -> {
    system.out.println(request.params("name")); //null is displayed
  });

  get("/:name", (request, respoonse) -> request.params("name"));
}

Cool sauce

python


public static void main(String[] args) {

  before("/:name", (request, response) -> {
    system.out.println(request.params("name")); //The content specified in the url is displayed
  });

  get("/:name", (request, respoonse) -> request.params("name"));
}

It feels a bit redundant.

Recommended Posts

Where to get lost in specifications with Spark routing
How to get values in real time with TextWatcher (Android)
How to get started with slim
How to get boolean value with jQuery in rails simple form
How to get along with Rails
Memo to get with Struts2 + Ajax
[Note] I want to get in reverse order using afterLast with JdbcTemplate
[Rails] How to get the user information currently logged in with devise
I tried to get started with WebAssembly
Get multiple records conditionally with where method
[Note] How to get started with Rspec
[rails] How to configure routing in resources
How to get the date in java
How to get keycloak credentials in interceptor class
How to get along with Rails
When you get lost in the class name
How to get Class from Element in Java
Map GET requests to complex objects in Spring.
How to get started with Eclipse Micro Profile
Library "OSHI" to get system information in Java
One way to redirect_to with parameters in rails
Try to get redmine API key with ruby
Rails beginners tried to get started with RSpec
How to get resource files out with spring-boot
Get along with Java containers in Cloud Run
I want to get the value in Ruby