Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 12 additions & 35 deletions docs/get-started/foundations/infrastructure/resources.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,17 @@ import (
)

func main() {
api, err := nitric.NewApi("public")
if err != nil {
fmt.Println(err)
return
}
api := nitric.NewApi("public")

// ✅ This declaration will work
bucket, err := nitric.NewBucket("files").Allow(nitric.BucketRead)
bucket := nitric.NewBucket("files").Allow(nitric.BucketRead)

api.Get("/files/:name", func(ctx *apis.Ctx) {
// ❌ This declaration won't work, since it's in a callback that's only called at runtime.
badBucket, err := nitric.NewBucket("wont-work").Allow(nitric.BucketRead)
badBucket := nitric.NewBucket("wont-work").Allow(nitric.BucketRead)
})

if err := nitric.Run(); err != nil {
fmt.Println(err)
}

fmt.Println("Service has started")
nitric.Run()
}
```

Expand Down Expand Up @@ -202,14 +194,14 @@ import (
)

func main() {
api, err := nitric.NewApi("public")
api := nitric.NewApi("public")
if err != nil {
fmt.Println(err)
return
}


bucket, err := nitric.NewBucket("files").Allow(nitric.BucketRead)
bucket := nitric.NewBucket("files").Allow(nitric.BucketRead)

// ❌ This access will not work
fileContents, _ := bucket.Read(context.TODO(), "example.txt")
Expand All @@ -219,9 +211,7 @@ func main() {
fileContents, _ := bucket.Read(context.TODO(), "example.txt")
})

if err := nitric.Run(); err != nil {
fmt.Println(err)
}
nitric.Run()
}
```

Expand Down Expand Up @@ -389,10 +379,7 @@ var PublicApi nitric.Api
var UpdateTopic nitric.SubscribableTopic

func init() {
publicApi, err := nitric.NewApi("public")
if err != nil {
panic(err)
}
publicApi := nitric.NewApi("public")

PublicApi = publicApi

Expand Down Expand Up @@ -424,9 +411,7 @@ func main() {
})
})

if err := nitric.Run(); err != nil {
fmt.Println(err)
}
nitric.Run()
}
```

Expand All @@ -445,11 +430,7 @@ func main() {
println("got the message")
})

if err := nitric.Run(); err != nil {
fmt.Println(err)
}

fmt.Println("Updates service has started")
nitric.Run()
}
```

Expand Down Expand Up @@ -644,9 +625,7 @@ func main() {
// do something with the file
})

if err := nitric.Run(); err != nil {
fmt.Println(err)
}
nitric.Run()
}
```

Expand All @@ -666,9 +645,7 @@ func main() {
// do something with the file
})

if err := nitric.Run(); err != nil {
fmt.Println(err)
}
nitric.Run()
}
```

Expand Down
10 changes: 2 additions & 8 deletions docs/get-started/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,7 @@ import (
)

func main() {
api, err := nitric.NewApi("main")
if err != nil {
fmt.Println(err)
return
}
api := nitric.NewApi("main")

api.Get("/hello/:name", func(ctx *apis.Ctx) {
name := ctx.Request.PathParams()["name"]
Expand All @@ -353,9 +349,7 @@ func main() {
ctx.Response.Body = []byte(fmt.Sprintf("Goodbye %s", name))
})

if err := nitric.Run(); err != nil {
fmt.Println(err)
}
nitric.Run()
}
```

Expand Down
4 changes: 1 addition & 3 deletions docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ import (
func main() {
profiles, _ := nitric.NewBucket("profiles").Allow(nitric.BucketRead, nitric.BucketWrite, nitric.BucketDelete)

if err := nitric.Run(); err != nil {
fmt.Println(err)
}
nitric.Run()
}
```

Expand Down
5 changes: 1 addition & 4 deletions docs/reference/go/api/api-delete.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ import (
)

func main() {
api, err := nitric.NewApi("public")
if err != nil {
return
}
api := nitric.NewApi("public")

api.Delete("/hello", func(ctx *apis.Ctx) {
ctx.Response.Body = []byte("Hello World")
Expand Down
15 changes: 3 additions & 12 deletions docs/reference/go/storage/bucket-downloadurl.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ import (
)

func main() {
bucket, err := nitric.NewBucket("bucket-name").Allow(nitric.BucketRead)
if err != nil {
return
}
bucket := nitric.NewBucket("bucket-name").Allow(nitric.BucketRead)

downloadUrl, err := bucket.File("cat.png").DownloadUrl(context.TODO(), "cat.png", storage.WithPresignUrlExpiry(time.Minute*5))
if err != nil {
Expand All @@ -80,15 +77,9 @@ import (
)

func main() {
api, err := nitric.NewApi("main")
if err != nil {
return
}
api := nitric.NewApi("main")

bucket, err := nitric.NewBucket("images").Allow(nitric.BucketRead)
if err != nil {
return
}
bucket := nitric.NewBucket("images").Allow(nitric.BucketRead)

api.Get("/images/:id", func(ctx *apis.Ctx) {
id := ctx.Request.PathParams()["id"]
Expand Down
Loading