api

package
v0.0.0-...-e41b7d6 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package api provides primitives to interact with the openapi HTTP API.

Code generated by github.com/discord-gophers/goapi-gen version v0.3.0 DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSwagger

func GetSwagger() (swagger *openapi3.T, err error)

GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.

func Handler

func Handler(si ServerInterface, opts ...ServerOption) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

Types

type ConnectParams

type ConnectParams struct {
	// The temporary oauth grant code
	Code *string `json:"code,omitempty"`

	// The error message
	Error *string `json:"error,omitempty"`
}

ConnectParams defines parameters for Connect.

type Error

type Error struct {
	Code    int32  `json:"code"`
	Message string `json:"message"`
}

Error defines model for Error.

type InvalidParamFormatError

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

func (InvalidParamFormatError) Error

func (err InvalidParamFormatError) Error() string

Error implements error.

func (InvalidParamFormatError) ParamName

func (err InvalidParamFormatError) ParamName() string

func (InvalidParamFormatError) Unwrap

func (err InvalidParamFormatError) Unwrap() error

type ParameterError

type ParameterError interface {
	error
	// ParamName is the name of the parameter that the error is referring to.
	ParamName() string
}

ParameterName is an interface that is implemented by error types that are relevant to a specific parameter.

type RequiredHeaderError

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

func (RequiredHeaderError) Error

func (err RequiredHeaderError) Error() string

Error implements error.

func (RequiredHeaderError) ParamName

func (err RequiredHeaderError) ParamName() string

type RequiredParamError

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

func (RequiredParamError) Error

func (err RequiredParamError) Error() string

Error implements error.

func (RequiredParamError) ParamName

func (err RequiredParamError) ParamName() string

func (RequiredParamError) Unwrap

func (err RequiredParamError) Unwrap() error

type Response

type Response struct {
	Code int
	// contains filtered or unexported fields
}

Response is a common response struct for all the API calls. A Response object may be instantiated via functions for specific operation responses. It may also be instantiated directly, for the purpose of responding with a single status code.

func ConnectJSON500Response

func ConnectJSON500Response(body Error) *Response

ConnectJSON500Response is a constructor method for a Connect response. A *Response is returned with the configured status code and content type from the spec.

func ImportSTIXJSON500Response

func ImportSTIXJSON500Response(body Error) *Response

ImportSTIXJSON500Response is a constructor method for a ImportSTIX response. A *Response is returned with the configured status code and content type from the spec.

func (*Response) ContentType

func (resp *Response) ContentType(contentType string) *Response

ContentType is a builder method to override the default content type for a response.

func (*Response) MarshalJSON

func (resp *Response) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. This is used to only marshal the body of the response.

func (*Response) MarshalXML

func (resp *Response) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML implements the xml.Marshaler interface. This is used to only marshal the body of the response.

func (*Response) Render

func (resp *Response) Render(w http.ResponseWriter, r *http.Request) error

Render implements the render.Renderer interface. It sets the Content-Type header and status code based on the response definition.

func (*Response) Status

func (resp *Response) Status(code int) *Response

Status is a builder method to override the default status code for a response.

type ServerInterface

type ServerInterface interface {
	// Get homepage
	// (GET /)
	GetHomePage(w http.ResponseWriter, r *http.Request) *Response

	// (GET /api/events)
	GetEvents(w http.ResponseWriter, r *http.Request) *Response
	// Import STIX data into Notion
	// (GET /api/import)
	ImportSTIX(w http.ResponseWriter, r *http.Request) *Response
	// Connect the Notion STIX Integration
	// (GET /auth/notion/callback)
	Connect(w http.ResponseWriter, r *http.Request, params ConnectParams) *Response
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler          ServerInterface
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) Connect

Connect operation middleware

func (*ServerInterfaceWrapper) GetEvents

func (siw *ServerInterfaceWrapper) GetEvents(w http.ResponseWriter, r *http.Request)

GetEvents operation middleware

func (*ServerInterfaceWrapper) GetHomePage

func (siw *ServerInterfaceWrapper) GetHomePage(w http.ResponseWriter, r *http.Request)

GetHomePage operation middleware

func (*ServerInterfaceWrapper) ImportSTIX

func (siw *ServerInterfaceWrapper) ImportSTIX(w http.ResponseWriter, r *http.Request)

ImportSTIX operation middleware

type ServerOption

type ServerOption func(*ServerOptions)

func WithErrorHandler

func WithErrorHandler(handler func(w http.ResponseWriter, r *http.Request, err error)) ServerOption

func WithRouter

func WithRouter(r chi.Router) ServerOption

func WithServerBaseURL

func WithServerBaseURL(url string) ServerOption

type ServerOptions

type ServerOptions struct {
	BaseURL          string
	BaseRouter       chi.Router
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type TooManyValuesForParamError

type TooManyValuesForParamError struct {
	NumValues int
	// contains filtered or unexported fields
}

func (TooManyValuesForParamError) Error

func (err TooManyValuesForParamError) Error() string

Error implements error.

func (TooManyValuesForParamError) ParamName

func (err TooManyValuesForParamError) ParamName() string

type UnescapedCookieParamError

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

func (UnescapedCookieParamError) Error

func (err UnescapedCookieParamError) Error() string

Error implements error.

func (UnescapedCookieParamError) ParamName

func (err UnescapedCookieParamError) ParamName() string

func (UnescapedCookieParamError) Unwrap

func (err UnescapedCookieParamError) Unwrap() error

type UnmarshalingParamError

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

func (UnmarshalingParamError) Error

func (err UnmarshalingParamError) Error() string

Error implements error.

func (UnmarshalingParamError) ParamName

func (err UnmarshalingParamError) ParamName() string

func (UnmarshalingParamError) Unwrap

func (err UnmarshalingParamError) Unwrap() error

Jump to

Keyboard shortcuts

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