go-sdk

command module
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

README

Nitric Logo

Build nitric applications with Python

codecov Version Go report card

Go SDK for Nitric

The Go SDK supports the use of the Nitric framework with GoLang 1.16. For more information, check out the main Nitric repo.

Nitric SDKs provide an infrastructure-as-code style that lets you define resources in code. You can also write the functions that support the logic behind APIs, subscribers and schedules.

You can request the type of access you need to resources such as publishing for topics, without dealing directly with IAM or policy documents.

Status

The SDK is in early stage development and APIs and interfaces are still subject to breaking changes. We’d love your feedback as we build additional functionality!

Get in touch

Get Started

Check out the Nitric docs to see how to get started using Nitric.

Documentation

Overview

Package go-sdk is the Go SDK for the Nitric framework.

Introduction

The Go SDK supports the use of the Nitric framework with Go 1.17+. For more information, check out the main Nitric repo.

Nitric SDKs provide an infrastructure-as-code style that lets you define resources in code. You can also write the functions that support the logic behind APIs, subscribers and schedules. You can request the type of access you need to resources such as publishing for topics, without dealing directly with IAM or policy documents.

A good starting point is to check out [resources.NewApi] function.

exampleApi, err := resources.NewApi("example")
if err != nil {
	fmt.Println(err)
	os.Exit(1)
}

exampleApi.Get("/hello/:name", func(ctx *faas.HttpContext, next faas.HttpHandler) (*faas.HttpContext, error) {
	params := ctx.Request.PathParams()

	if params == nil || len(params["name"]) == 0 {
		ctx.Response.Body = []byte("error retrieving path params")
		ctx.Response.Status = http.StatusBadRequest
	} else {
		ctx.Response.Body = []byte("Hello " + params["name"])
		ctx.Response.Status = http.StatusOK
	}

	return next(ctx)
})

fmt.Println("running example API")
if err := resources.Run(); err != nil {
	fmt.Println(err)
	os.Exit(1)
}

Directories

Path Synopsis
api
Package mock_v1 is a generated GoMock package.
Package mock_v1 is a generated GoMock package.
mockapi
Package mockapi is a generated GoMock package.
Package mockapi is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL