runtime

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Copyright 2019 DeepMap, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 DeepMap, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 DeepMap, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 DeepMap, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	// ErrSecurityProviderApiKeyInvalidIn indicates a usage of an invalid In.
	// Should be cookie, header or query
	ErrSecurityProviderApiKeyInvalidIn = SecurityProviderError("invalid 'in' specified for apiKey")
)

Variables

This section is empty.

Functions

func BindQueryParameter

func BindQueryParameter(style string, explode bool, required bool, paramName string,
	queryParams url.Values, dest interface{}) error

This works much like BindStyledParameter, however it takes a query argument input array from the url package, since query arguments come through a different path than the styled arguments. They're also exceptionally fussy. For example, consider the exploded and unexploded form parameter examples: (exploded) /users?role=admin&firstName=Alex (unexploded) /users?id=role,admin,firstName,Alex

In the first case, we can pull the "id" parameter off the echo context, and unmarshal via json as an intermediate. Easy. In the second case, we don't have the id QueryParam present, but must find "role", and "firstName". what if there is another parameter similar to "ID" named "role"? We can't tell them apart. This code tries to fail, but the moral of the story is that you shouldn't pass objects via form styled query arguments, just use the Content parameter form.

func BindStringToObject

func BindStringToObject(src string, dst interface{}) error

This function takes a string, and attempts to assign it to the destination interface via whatever type conversion is necessary. We have to do this via reflection instead of a much simpler type switch so that we can handle type aliases. This function was the easy way out, the better way, since we know the destination type each place that we use this, is to generate code to read each specific type.

func BindStyledParameter

func BindStyledParameter(style string, explode bool, paramName string,
	value string, dest interface{}) error

This function binds a parameter as described in the Path Parameters section here to a Go object: https://swagger.io/docs/specification/serialization/

func StyleParam

func StyleParam(style string, explode bool, paramName string, value interface{}) (string, error)

Given an input value, such as a primitive type, array or object, turn it into a parameter based on style/explode definition.

Types

type EchoRouter

type EchoRouter interface {
	CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}

This is a simple interface which specifies echo.Route addition functions which are present on both echo.Echo and echo.Group, since we want to allow using either of them for path registration

type SecurityProviderApiKey

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

SecurityProviderApiKey will attach an apiKey either to a cookie, header or query.

func NewSecurityProviderApiKey

func NewSecurityProviderApiKey(in, name, apiKey string) (*SecurityProviderApiKey, error)

NewSecurityProviderApiKey will attach a generic apiKey for a given name either to a cookie, header or as a query parameter.

func (*SecurityProviderApiKey) Intercept

func (s *SecurityProviderApiKey) Intercept(req *http.Request, ctx context.Context) error

Intercept will attach a cookie, header or query param for the configured name and apiKey.

type SecurityProviderBasicAuth

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

SecurityProviderBasicAuth sends a base64-encoded combination of username, password along with a request.

func NewSecurityProviderBasicAuth

func NewSecurityProviderBasicAuth(username, password string) (*SecurityProviderBasicAuth, error)

NewSecurityProviderBasicAuth provides a SecurityProvider, which can solve the BasicAuth challenge for api-calls.

func (*SecurityProviderBasicAuth) Intercept

func (s *SecurityProviderBasicAuth) Intercept(req *http.Request, ctx context.Context) error

Intercept will attach an Authorization header to the request and ensures that the username, password are base64 encoded and attached to the header.

type SecurityProviderBearerToken

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

SecurityProviderBearerToken sends a token as part of an Authorization: Bearer header along with a request.

func NewSecurityProviderBearerToken

func NewSecurityProviderBearerToken(token string) (*SecurityProviderBearerToken, error)

NewSecurityProviderBearerToken provides a SecurityProvider, which can solve the Bearer Auth challende for api-calls.

func (*SecurityProviderBearerToken) Intercept

func (s *SecurityProviderBearerToken) Intercept(req *http.Request, ctx context.Context) error

Intercept will attach an Authorization header to the request and ensures that the bearer token is attached to the header.

type SecurityProviderError

type SecurityProviderError string

SecurityProviderError defines error values of a security provider.

func (SecurityProviderError) Error

func (e SecurityProviderError) Error() string

Error implements the error interface.

Jump to

Keyboard shortcuts

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