Go is in development for v1. Interested in contributing or chatting with us?Get in touch!
Go - Api.Details()
Retrieve details about the deployed API at runtime. These details include:
ID
: the identifier for the resource.Provider
: the cloud provider that this API is deployed to.Service
: the cloud service that is running this API (i.e. AWS API Gateway).URL
: the URL of the deployed API.
import (
"fmt"
"context"
"github.com/nitrictech/go-sdk/nitric"
)
func main() {
api, err := nitric.NewApi("public")
if err != nil {
return
}
details, err := api.Details(context.TODO())
if err != nil {
return
}
if err := nitric.Run(); err != nil {
fmt.Println(err)
}
}
Parameters
- Name
ctx
- Required
- Required
- Type
- context
- Description
The context of the call, used for tracing.
Examples
Get the URL of a deployed API
import (
"fmt"
"context"
"github.com/nitrictech/go-sdk/nitric"
)
func main() {
api, err := nitric.NewApi("public")
if err != nil {
return
}
details, err := api.Details(context.TODO())
if err != nil {
return
}
fmt.Println(details.URL)
if err := nitric.Run(); err != nil {
fmt.Println(err)
}
}