-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsr_echo_request_handler.erl
More file actions
43 lines (39 loc) · 1.01 KB
/
sr_echo_request_handler.erl
File metadata and controls
43 lines (39 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
%%% @doc /echo handler
-module(sr_echo_request_handler).
-behaviour(trails_handler).
-include_lib("mixer/include/mixer.hrl").
-mixin([{ sr_single_entity_handler
, [ init/3
, rest_init/2
, allowed_methods/2
, resource_exists/2
, content_types_accepted/2
, content_types_provided/2
, handle_put/2
]
}]).
-export([ trails/0
]).
-spec trails() -> trails:trails().
trails() ->
RequestBody =
#{ name => <<"request body">>
, in => body
, description => <<"request body (as json)">>
, required => true
},
Metadata =
#{ put =>
#{ tags => ["echo"]
, description => "save an echo request"
, consumes => ["application/json"]
, produces => ["application/json"]
, parameters => [RequestBody]
}
},
Path = "/echo/:id",
Opts = #{ path => Path
, model => echo_request
, verbose => true
},
[trails:trail(Path, ?MODULE, Opts, Metadata)].