mirror of
https://github.com/taigrr/nats.docs
synced 2025-01-18 04:03:23 -08:00
GitBook: [master] 82 pages modified
This commit is contained in:
committed by
gitbook-bot
parent
7e27f03c98
commit
b082996143
@@ -25,7 +25,7 @@ Given a creds file, a client can authenticate as a specific user belonging to a
|
||||
```go
|
||||
nc, err := nats.Connect("127.0.0.1", nats.UserCredentials("path_to_creds_file"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
|
||||
@@ -9,11 +9,11 @@ Handling challenge response may require more than just a setting in the connecti
|
||||
```go
|
||||
opt, err := nats.NkeyOptionFromSeed("seed.txt")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Fatal(err)
|
||||
}
|
||||
nc, err := nats.Connect("127.0.0.1", opt)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ Connecting to a server with TLS is straightforward. Most clients will automatica
|
||||
{% tab title="Go" %}
|
||||
```go
|
||||
nc, err := nats.Connect("localhost",
|
||||
nats.ClientCert("resources/certs/cert.pem", "resources/certs/key.pem"),
|
||||
nats.RootCAs("resources/certs/ca.pem"))
|
||||
nats.ClientCert("resources/certs/cert.pem", "resources/certs/key.pem"),
|
||||
nats.RootCAs("resources/certs/ca.pem"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
@@ -84,7 +84,7 @@ public class ConnectTLS {
|
||||
sslContext(ctx). // Set the SSL context
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
@@ -206,7 +206,7 @@ Some clients may support the `tls` protocol as well as a manual setting to turn
|
||||
```go
|
||||
nc, err := nats.Connect("tls://localhost", nats.RootCAs("resources/certs/ca.pem")) // May need this if server is using self-signed certificate
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
@@ -269,7 +269,7 @@ public class ConnectTLS {
|
||||
sslContext(ctx). // Set the SSL context
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
|
||||
@@ -18,7 +18,7 @@ The code uses localhost:4222 so that you can start the server on your machine to
|
||||
// Set a token
|
||||
nc, err := nats.Connect("127.0.0.1", nats.Name("API Token Example"), nats.Token("mytoken"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
@@ -85,7 +85,7 @@ Again, once you construct this URL you can connect as if this was a normal URL.
|
||||
// Token in URL
|
||||
nc, err := nats.Connect("mytoken@localhost")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ When logging in with a password `nats-server` will take either a plain text pass
|
||||
// Set a user and plain text password
|
||||
nc, err := nats.Connect("127.0.0.1", nats.UserInfo("myname", "password"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
@@ -109,7 +109,7 @@ Using this format, you can connect to a server using authentication as easily as
|
||||
// Set a user and plain text password
|
||||
nc, err := nats.Connect("myname:password@127.0.0.1")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user