File tree Expand file tree Collapse file tree 2 files changed +40
-9
lines changed
app/controllers/rails/keyserver/api/v1 Expand file tree Collapse file tree 2 files changed +40
-9
lines changed Original file line number Diff line number Diff line change @@ -11,10 +11,6 @@ image:https://img.shields.io/codeclimate/maintainability/riboseinc/rails-keyserv
11
11
12
12
A generic Rails engine for serving most kinds of keys.
13
13
14
- == Usage
15
-
16
- How to use my plugin.
17
-
18
14
== Installation
19
15
20
16
Add this line to your application’s Gemfile:
@@ -105,6 +101,27 @@ endpoints:
105
101
}
106
102
----
107
103
104
+ == Usage
105
+
106
+ === Override controllers and rendering methods
107
+
108
+ ==== Keys Controller
109
+
110
+ * `#render_index`
111
+ ** `@composed` is the collection to render
112
+ * `#render_show_json(key)`
113
+ * `#render_show_ext(key)`
114
+
115
+ ==== Default settings for mounted routes
116
+
117
+ [source,ruby]
118
+ ----
119
+ # E.g. in config/routes.rb
120
+ mount_keyserver at: 'ks', controllers: {
121
+ keys: 'rails/keyserver/api/v1/keys',
122
+ }
123
+ ----
124
+
108
125
== Contributing
109
126
110
127
First, thank you for contributing! We love pull requests from everyone.
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ def set_composed
23
23
end
24
24
25
25
def index
26
- render json : @composed . all
26
+ render_index
27
27
end
28
28
29
29
def show
@@ -40,17 +40,31 @@ def show
40
40
41
41
respond_to do |format |
42
42
format . json do
43
- render json : key
43
+ render_show_json ( key )
44
44
end
45
45
46
46
# If .pub requested, send key.public as an attachment.
47
47
format . send ( RK ::Key ::PGP . extension ) do
48
- render_options = { }
49
- render_options [ :"#{ RK ::Key ::PGP . extension } " ] = key
50
- render render_options
48
+ render_show_ext ( key )
51
49
end
52
50
end
53
51
end
52
+
53
+ protected
54
+
55
+ def render_index
56
+ render json : @composed . all
57
+ end
58
+
59
+ def render_show_json ( key )
60
+ render json : key
61
+ end
62
+
63
+ def render_show_ext ( key )
64
+ render_options = { }
65
+ render_options [ :"#{ RK ::Key ::PGP . extension } " ] = key
66
+ render render_options
67
+ end
54
68
end
55
69
end
56
70
end
You can’t perform that action at this time.
0 commit comments