Skip to content

Commit 96373aa

Browse files
Fennygitbook-bot
authored andcommitted
GitBook: [master] one page modified
1 parent b3105d1 commit 96373aa

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

application.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ Binds and listens for connections on the specified address. This can be a `int`
258258

259259
{% code title="Signature" %}
260260
```go
261-
app.Listen(address interface{}, tls ...*tls.Config)
261+
app.Listen(address interface{}, tls ...*tls.Config) error
262262
```
263263
{% endcode %}
264264

@@ -285,6 +285,30 @@ app.Listen(443, config)
285285
```
286286
{% endcode %}
287287

288+
## Serve
289+
290+
You can pass your own [`net.Listener`](https://golang.org/pkg/net/#Listener) using the `Serve` method.
291+
292+
{% code title="Signature" %}
293+
```go
294+
app.Serve(ln net.Listener, tls ...*tls.Config) error
295+
```
296+
{% endcode %}
297+
298+
{% hint style="warning" %}
299+
**Serve** does not support the ****[**Prefork** ](application.md#settings)feature.
300+
{% endhint %}
301+
302+
{% code title="Example" %}
303+
```go
304+
if ln, err = net.Listen("tcp4", ":8080"); err != nil {
305+
log.Fatal(err)
306+
}
307+
308+
app.Serve(ln)
309+
```
310+
{% endcode %}
311+
288312
## Test
289313

290314
Testing your application is done with the **Test** method. Use this method for creating `_test.go` files or when you need to debug your routing logic. The default timeout is `200ms` if you want to disable a timeout completely, pass `-1` as a second argument.

0 commit comments

Comments
 (0)