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: README.md
+7-8Lines changed: 7 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -304,7 +304,7 @@ func Handle(w http.ResponseWriter, r *http.Request) {
304
304
305
305
For this example you will need to be using Go 1.13 or newer and Go modules, enable this via `faas-cli build --build-arg GO111MODULE=on`.
306
306
307
-
Imagine you have a package which you want to store outside of the `handler.go` file, it's another middleware which can perform an echo.
307
+
Imagine you have a package which you want to store outside of the `handler.go` file, it's another middleware which can perform an echo of the user's input.
308
308
309
309
```Golang
310
310
package handlers
@@ -315,26 +315,25 @@ import (
315
315
)
316
316
317
317
funcEcho(whttp.ResponseWriter, r *http.Request) {
318
-
319
318
if r.Body != nil {
320
319
defer r.Body.Close()
321
320
b, _:= ioutil.ReadAll(r.Body)
322
321
w.Write(b)
323
322
}
324
-
325
323
}
326
324
```
327
325
328
-
To include a relative module such as this new `handlers` package, you should create a `GO_REPLACE.txt` file as follows.
329
-
330
-
Let's say your GOPATH for your GitHub repo is: `github.com/alexellis/vault/` and your OpenFaaS function is `purchase` generated by `faas-cli new purchase --lang golang-middleware`.
331
-
332
-
Your relative GOPATH is: `github.com/alexellis/vault/purchase`, so add a redirect as per below to redirect the "handlers" package to where it exists in the build container.
326
+
To include a relative module such as this new `handlers` package, you should create a `GO_REPLACE.txt` file as follows:
How did we get to that? Let's say your GOPATH for your GitHub repo is: `github.com/alexellis/vault/` and your OpenFaaS function is `purchase` generated by `faas-cli new purchase --lang golang-middleware`.
333
+
334
+
Your relative GOPATH is: `github.com/alexellis/vault/purchase`, so add a redirect as per below to redirect the "handlers" package to where it exists in the build container.
335
+
336
+
338
337
Now if you want to reference the handlers package from within your `handler.go` write the following:
0 commit comments