You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cli/templates.md
+36-5
Original file line number
Diff line number
Diff line change
@@ -129,13 +129,44 @@ npm i --save cheerio
129
129
130
130
You can now add a `require('cheerio')` statement into your function and make use of this library.
131
131
132
-
## 4.0 Customise a template
132
+
## 4.0 Java
133
+
134
+
A Java 8 template is provided which uses Gradle 4.8.1 as a build-system.
135
+
136
+
Support is made available for external code repositories via the build.gradle file where you specify dependencies to fetch from repositories or JAR files to be added via the build.
137
+
138
+
* Write a function `java-function`:
139
+
140
+
```
141
+
$ faas-cli new --lang java8 java-function
142
+
```
143
+
144
+
* Write your code in:
145
+
146
+
./src/main/Handler.java
147
+
148
+
* Write `junit` tests in:
149
+
150
+
./src/tests/
151
+
152
+
* Update gradle config if needed in:
153
+
154
+
./build.gradle
155
+
./settings.gradle
156
+
157
+
* Working with headers
158
+
159
+
You can use `getHeader(k)` on the Request interface to query a header.
160
+
161
+
To set a header such as content-type you can use `setHeader(k, v)` on the Response interface.
162
+
163
+
## 5.0 Customise a template
133
164
134
165
It is recommended that you use the official templates as they are provided and if there is a short-coming that you raise a GitHub issue so we can improve the templates for everyone.
135
166
136
167
All templates are driven by a Dockerfile and can be customised by editing the files found in the ./template folder.
137
168
138
-
### 4.1 Update the Dockerfile
169
+
### 5.1 Update the Dockerfile
139
170
140
171
There are several reasons why you may want to update your Dockerfile, just edit `./template/<language_name>/Dockerfile`.
141
172
@@ -145,7 +176,7 @@ There are several reasons why you may want to update your Dockerfile, just edit
145
176
146
177
* Try a new version of a base-image - it may be that the project is showing support for Node.js LTS, but you want the cutting-edge version, you can do that too
147
178
148
-
### 4.2 Update a template's configuration
179
+
### 5.2 Update a template's configuration
149
180
150
181
The name of a template is read from a "template.yml" file kept within the template folder: `./template/<language_name>/template.yml`
151
182
@@ -159,13 +190,13 @@ fprocess: dotnet ./root.dll
159
190
*`language` is the display name used for `faas-cli new --list`.
160
191
*`fprocess` provides the process to run for each invocation - i.e. your function
161
192
162
-
### 4.3 Use your own templates
193
+
### 5.3 Use your own templates
163
194
164
195
You can use your own Git repository for a custom or forked set of templates. This can be public or private.
165
196
166
197
See `faas-cli template pull` for more information.
167
198
168
-
### 5.0 ARM / Raspberry Pi
199
+
### 6.0 ARM / Raspberry Pi
169
200
170
201
Templates for ARM and Raspberry Pi are provided on a best-effort basis. If you can help with maintenance please let the project contributors know.
0 commit comments