This repository was archived by the owner on Apr 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed
src/main/java/de/filefighter/rest/rest Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ package de .filefighter .rest .rest ;
2
+
3
+ import org .springframework .boot .web .servlet .error .ErrorController ;
4
+ import org .springframework .hateoas .EntityModel ;
5
+ import org .springframework .web .bind .annotation .RequestMapping ;
6
+ import org .springframework .web .bind .annotation .RestController ;
7
+ import springfox .documentation .annotations .ApiIgnore ;
8
+
9
+ @ ApiIgnore
10
+ @ RestController
11
+ public class RestErrorController implements ErrorController {
12
+
13
+ private static final String DEFAULT_PATH = "/error" ;
14
+
15
+ @ RequestMapping (value = DEFAULT_PATH )
16
+ public EntityModel <ServerResponse > error () {
17
+ return new ServerResponse ("denied" , "This endpoint does not exist." ).toModel ();
18
+ }
19
+
20
+ @ Override
21
+ public String getErrorPath () {
22
+ return DEFAULT_PATH ;
23
+ }
24
+ }
Original file line number Diff line number Diff line change
1
+ package de .filefighter .rest .rest ;
2
+
3
+ import lombok .Data ;
4
+ import org .springframework .hateoas .EntityModel ;
5
+
6
+ @ Data
7
+ public class ServerResponse {
8
+ private String message ;
9
+ private String status ;
10
+
11
+ public ServerResponse (String status , String message ) {
12
+ this .status = status ;
13
+ this .message = message ;
14
+ }
15
+
16
+ public EntityModel <ServerResponse > toModel () {
17
+ return EntityModel .of (this );
18
+ }
19
+ }
You can’t perform that action at this time.
0 commit comments