Listen

Binds and listens for connections on the specified address. This can be a int for port or string for address.

  1. app.Listen(address interface{}, tls ...*tls.Config) error
  1. app.Listen(8080)
  2. app.Listen("8080")
  3. app.Listen(":8080")
  4. app.Listen("127.0.0.1:8080")

To enable TLS/HTTPS you can append a TLS config.

  1. cer, err := tls.LoadX509KeyPair("server.crt", "server.key")
  2. if err != nil {
  3. log.Fatal(err)
  4. }
  5. config := &tls.Config{Certificates: []tls.Certificate{cer}}
  6.  
  7. app.Listen(443, config)