perwendel / spark

A simple expressive web framework for java. Spark has a kotlin DSL https://github.com/perwendel/spark-kotlin
Apache License 2.0
9.63k stars 1.56k forks source link

How to route .html url extension #1032

Open CreateChen opened 6 years ago

CreateChen commented 6 years ago

Code like this:

get("/article/:id.html", (request, response)->{ return request.params(":id"); });

toyknight commented 6 years ago

I guess you will have to use wildcard pattern and extract that id from url manually (like using regex group).

tipsy commented 6 years ago

Why not use the static file handler?

CreateChen commented 6 years ago

Because the .html is dynamic page :-)

Some search engines prefer url end with .html, and give the domain a higher weight.

kaibioinfo commented 4 years ago

I have the same problem. For REST APIs I like to define an output type like HTML, JSON, CSV and so on. I don't understand why such a basic functionality is not part of the route engine.