app

package module
v0.0.0-...-786563c Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

oapi-sample

OpenAPI and sqlc sample project

Requirements

  • Go 1.17
  • oapi-codegen
  • sqlc
  • postgresql 13

Setup

cd .devcontainer
docker compose up -d

go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.8.2
go install github.com/kyleconroy/sqlc/cmd/sqlc@latest

Build

go build cmd/server/main.go

Run

go run cmd/server/main.go

Generate

Updates docs/openapi.yaml or sql//**.sql. generate.

go generate

or

for docs/openapi.yaml

oapi-codegen --config=types.cfg.yaml docs/openapi.yaml
oapi-codegen --config=server.cfg.yaml docs/openapi.yaml

for sql//**.sql

sqlc generate -f sqlc.yaml

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectDB

func ConnectDB(conn *sql.DB) (*db.Queries, error)

Types

type ItemStore

type ItemStore struct {
	// contains filtered or unexported fields
}

func NewItemStore

func NewItemStore(queries *db.Queries, ctx context.Context) *ItemStore

func (*ItemStore) DeleteItem

func (i *ItemStore) DeleteItem(w http.ResponseWriter, r *http.Request, itemId openapi.ItemId)

func (*ItemStore) GetItemById

func (i *ItemStore) GetItemById(w http.ResponseWriter, r *http.Request, itemId openapi.ItemId)

func (*ItemStore) GetItems

func (i *ItemStore) GetItems(w http.ResponseWriter, r *http.Request, params openapi.GetItemsParams)

func (*ItemStore) PatchItem

func (i *ItemStore) PatchItem(w http.ResponseWriter, r *http.Request, itemId openapi.ItemId)

func (*ItemStore) PostItems

func (i *ItemStore) PostItems(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis
cmd
server command
gen
db
openapi
Package openapi provides primitives to interact with the openapi HTTP API.
Package openapi provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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