restapi

package
Version: v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package restapi Petstore

This is a sample server Petstore server.  You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).  For this sample, you can use the api key `special-key` to test the authorization filters.
Schemes:
  http
Host: petstore.service.strato
BasePath: /api/v2
Version: 1.0.0

Consumes:
  - application/json

Produces:
  - application/json

swagger:meta

Index

Constants

View Source
const AuthKey contextKey = "Auth"

Variables

View Source
var (
	// SwaggerJSON embedded version of the swagger document used at generation time
	SwaggerJSON json.RawMessage
	// FlatSwaggerJSON embedded flattened version of the swagger document used at generation time
	FlatSwaggerJSON json.RawMessage
)

Functions

func Handler

func Handler(c Config) (http.Handler, error)

Handler returns an http.Handler given the handler configuration It mounts all the business logic implementers in the right routing.

func HandlerAPI added in v0.18.0

func HandlerAPI(c Config) (http.Handler, *operations.PetstoreAPI, error)

HandlerAPI returns an http.Handler given the handler configuration and the corresponding *Petstore instance. It mounts all the business logic implementers in the right routing.

Types

type Config

type Config struct {
	PetAPI
	StoreAPI
	Logger func(string, ...interface{})
	// InnerMiddleware is for the handler executors. These do not apply to the swagger.json document.
	// The middleware executes after routing but before authentication, binding and validation.
	InnerMiddleware func(http.Handler) http.Handler

	// Authorizer is used to authorize a request after the Auth function was called using the "Auth*" functions
	// and the principal was stored in the context in the "AuthKey" context value.
	Authorizer func(*http.Request) error

	// AuthRoles Applies when the "X-Auth-Roles" header is set
	AuthRoles func(token string) (interface{}, error)

	// Authenticator to use for all APIKey authentication
	APIKeyAuthenticator func(string, string, security.TokenAuthentication) runtime.Authenticator
	// Authenticator to use for all Bearer authentication
	BasicAuthenticator func(security.UserPassAuthentication) runtime.Authenticator
	// Authenticator to use for all Basic authentication
	BearerAuthenticator func(string, security.ScopedTokenAuthentication) runtime.Authenticator
}

Config is configuration for Handler

type PetAPI

type PetAPI interface {
	/* PetCreate Add a new pet to the store */
	PetCreate(ctx context.Context, params pet.PetCreateParams) middleware.Responder

	/* PetDelete Deletes a pet */
	PetDelete(ctx context.Context, params pet.PetDeleteParams) middleware.Responder

	/* PetGet Get pet by it's ID */
	PetGet(ctx context.Context, params pet.PetGetParams) middleware.Responder

	/* PetList List pets */
	PetList(ctx context.Context, params pet.PetListParams) middleware.Responder

	/* PetUpdate Update an existing pet */
	PetUpdate(ctx context.Context, params pet.PetUpdateParams) middleware.Responder

	/* PetUploadImage uploads an image */
	PetUploadImage(ctx context.Context, params pet.PetUploadImageParams) middleware.Responder
}

PetAPI

type StoreAPI

type StoreAPI interface {
	/* InventoryGet Returns pet inventories by status */
	InventoryGet(ctx context.Context, params store.InventoryGetParams) middleware.Responder

	/* OrderCreate Place an order for a pet */
	OrderCreate(ctx context.Context, params store.OrderCreateParams) middleware.Responder

	/* OrderDelete Delete purchase order by ID */
	OrderDelete(ctx context.Context, params store.OrderDeleteParams) middleware.Responder

	/* OrderGet Find purchase order by ID */
	OrderGet(ctx context.Context, params store.OrderGetParams) middleware.Responder
}

StoreAPI

Directories

Path Synopsis
pet

Jump to

Keyboard shortcuts

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