practicalli / practicalli/clojure-web-services

Configuring the webserver - examples

Open
#79 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

jetty web-server
Dominant language
Markdown
Stars
16
Forks
14
PR merge metrics
No merged PRs in 30d

Description

Hiding details about the web server

:send-server-version? false to stop returning the Server details in the header of its responses. :send-date-header? false to avoid including the date of the response.

Without these settings, the server will return details in the headings:

❯ http --verbose :8080/api/ping
GET /api/ping HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: localhost:8080
User-Agent: HTTPie/2.2.0

HTTP/1.1 200 OK
Content-Length: 5
Date: Tue, 29 Sep 2020 06:19:35 GMT
Server: Jetty(9.4.28.v20200408)Pong!

Stop the web server and start after adding config to startup command:

(defn jetty-start
  [handler opts]
  (jetty/run-jetty handler (-> opts (assoc :send-server-version? false
                                           :send-date-header? false
                                           :join? false)))) ;; false so that we can stop it at the repl!

Now the server does not return the details all the detals

❯ http --verbose :8080/api/ping
GET /api/ping HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: localhost:8080
User-Agent: HTTPie/2.2.0

HTTP/1.1 200 OK
Content-Length: 5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the jetty-start entry point and the HTTPie request examples in this issue. Document the :send-server-version? and :send-date-header? options, including the startup configuration and resulting response headers; done means the examples clearly show how to hide the server and date details.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
backend, documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.