middlewares

package
v10.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

README

Middlewares

Available predefined middlewares:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCORSMiddleware added in v10.4.0

func NewCORSMiddleware(cors CORS) atreugo.Middleware

NewCORSMiddleware returns the middleware with the configured properties

IMPORTANT: always use as last middleware (`server.UseAfter(...)`)

func RequestIDMiddleware

func RequestIDMiddleware(ctx *atreugo.RequestCtx) error

RequestIDMiddleware adds an identifier to the request Header name: X-Request-ID Header value: uuid4()

It's recomemded to add this middleware at first and before the view execution.

Types

type CORS added in v10.4.0

type CORS struct {
	// Specifies either the origins, which tells browsers to allow that origin
	// to access the resource; or else — for requests without credentials —
	// the "*" wildcard, to tell browsers to allow any origin to access the resource.
	AllowedOrigins []string

	// Specifies the method or methods allowed when accessing the resource.
	// This is used in response to a preflight request.
	// The conditions under which a request is preflighted are discussed above.
	AllowedMethods []string

	// This is used in response to a preflight request to indicate which HTTP headers
	// can be used when making the actual request.
	AllowedHeaders []string

	// Indicates whether or not the response to the request can be exposed when
	// the credentials flag is true. When used as part of a response to a preflight request,
	// this indicates whether or not the actual request can be made using credentials.
	// Note that simple GET requests are not preflighted, and so if a request is made
	// for a resource with credentials, if this header is not returned with the resource,
	// the response is ignored by the browser and not returned to web content.
	AllowCredentials bool

	// Indicates how long, in seconds, the results of a preflight request can be cached
	AllowMaxAge int

	// Header or headers to lets a server whitelist headers that browsers are allowed to access.
	ExposedHeaders []string
}

CORS properties.

Jump to

Keyboard shortcuts

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