liveBook · Manning

/mappings endpoint

As explained in Spring in Action, Sixth Edition

The /mappings endpoint is a Spring Boot Actuator HTTP endpoint that lists HTTP request handlers and their request mappings.

The /mappings endpoint is a Spring Boot Actuator endpoint that lists how HTTP requests are mapped to controllers and other handlers. section 15.2.2

Inspecting mappings from the running application

Request the endpoint with curl and format the JSON with jq: `curl localhost:8080/actuator/mappings | jq`. The response groups mappings by application context and dispatcher handler. section 15.2.2

Listing 15.2 HTTP mappings as shown by the /mappings endpoint
$ curl localhost:8080/actuator/mappings | jq
{
  "contexts": {
    "application-1": {
      "mappings": {
        "dispatcherHandlers": {
          "webHandler": [
...
            {
              "predicate": "{[/ingredients],methods=[GET]}",
              "handler": "public reactor.core.publisher.Flux<tacos.ingredients.Ingredient> tacos.ingredients.IngredientsController.allIngredients()",
              "details": {
                "handlerMethod": {
                  "className": "tacos.ingredients.IngredientsController",
                  "name": "allIngredients",
                  "descriptor": "()Lreactor/core/publisher/Flux;"
                },
                "handlerFunction": null,
                "requestMappingConditions": {
                  "consumes": [],
                  "headers": [],
                  "methods": [
                    "GET"
                  ],
                  "params": [],
                  "patterns": [
                    "/ingredients"
                  ],
                  "produces": []
                }
              }
            },
...
          ]
        }
      },
      "parentId": "application-1"
    },
    "bootstrap": {
      "mappings": {
        "dispatcherHandlers": {}
      },
      "parentId": null
    }
  }
}

Browse a representative response showing a GET mapping for `/ingredients`, its handler method, controller class, and request-mapping conditions. section 15.2.2

How Spring in Action, Sixth Edition covers it

How deep it goes
Shows mappings within application contexts, dispatcher handlers, predicates, handler methods, classes, and request-mapping conditions.
Examples
Uses curl and jq to inspect a GET `/ingredients` mapping handled by IngredientsController.allIngredients().
What it assumes
Assumes a running Spring Boot Actuator application with HTTP handlers and request mappings.
What you can do after
Diagnose routing configuration by inspecting registered paths, HTTP methods, handlers, and mapping conditions.
How it connects
Connects Spring Boot Actuator with HTTP request mappings, dispatcher handlers, controllers, and handler methods.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.