Listen
Binds and listens for connections on the specified address. This can be a int
for port or string
for address.
- app.Listen(address interface{}, tls ...*tls.Config) error
- app.Listen(8080)
- app.Listen("8080")
- app.Listen(":8080")
- app.Listen("127.0.0.1:8080")
To enable TLS/HTTPS you can append a TLS config.
- cer, err := tls.LoadX509KeyPair("server.crt", "server.key")
- if err != nil {
- log.Fatal(err)
- }
- config := &tls.Config{Certificates: []tls.Certificate{cer}}
- app.Listen(443, config)