2017-07-10 17:32:42 +02:00
|
|
|
package iris
|
|
|
|
|
|
|
|
import (
|
2019-10-25 00:27:02 +02:00
|
|
|
"github.com/kataras/iris/v12/context"
|
|
|
|
"github.com/kataras/iris/v12/core/host"
|
|
|
|
"github.com/kataras/iris/v12/core/router"
|
2020-04-18 21:40:47 +02:00
|
|
|
"github.com/kataras/iris/v12/hero"
|
2017-07-10 17:32:42 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
2020-01-12 14:43:31 +01:00
|
|
|
// Context is the middle-man server's "object" for the clients.
|
2017-07-10 17:32:42 +02:00
|
|
|
//
|
|
|
|
// A New context is being acquired from a sync.Pool on each connection.
|
|
|
|
// The Context is the most important thing on the iris's http flow.
|
|
|
|
//
|
|
|
|
// Developers send responses to the client's request through a Context.
|
|
|
|
// Developers get request information from the client's request by a Context.
|
|
|
|
Context = context.Context
|
2018-03-08 04:21:16 +01:00
|
|
|
// UnmarshalerFunc a shortcut, an alias for the `context#UnmarshalerFunc` type
|
|
|
|
// which implements the `context#Unmarshaler` interface for reading request's body
|
|
|
|
// via custom decoders, most of them already implement the `context#UnmarshalerFunc`
|
|
|
|
// like the json.Unmarshal, xml.Unmarshal, yaml.Unmarshal and every library which
|
|
|
|
// follows the best practises and is aligned with the Go standards.
|
|
|
|
//
|
|
|
|
// See 'context#UnmarshalBody` for more.
|
|
|
|
//
|
2020-06-07 14:26:06 +02:00
|
|
|
// Example: https://github.com/kataras/iris/blob/master/_examples/request-body/read-custom-via-unmarshaler/main.go
|
2018-03-08 04:21:16 +01:00
|
|
|
UnmarshalerFunc = context.UnmarshalerFunc
|
2017-07-10 17:32:42 +02:00
|
|
|
// A Handler responds to an HTTP request.
|
|
|
|
// It writes reply headers and data to the Context.ResponseWriter() and then return.
|
|
|
|
// Returning signals that the request is finished;
|
|
|
|
// it is not valid to use the Context after or concurrently with the completion of the Handler call.
|
|
|
|
//
|
|
|
|
// Depending on the HTTP client software, HTTP protocol version,
|
|
|
|
// and any intermediaries between the client and the iris server,
|
|
|
|
// it may not be possible to read from the Context.Request().Body after writing to the context.ResponseWriter().
|
|
|
|
// Cautious handlers should read the Context.Request().Body first, and then reply.
|
|
|
|
//
|
|
|
|
// Except for reading the body, handlers should not modify the provided Context.
|
|
|
|
//
|
|
|
|
// If Handler panics, the server (the caller of Handler) assumes that the effect of the panic was isolated to the active request.
|
|
|
|
// It recovers the panic, logs a stack trace to the server error log, and hangs up the connection.
|
|
|
|
Handler = context.Handler
|
2019-01-19 22:33:33 +01:00
|
|
|
// Filter is just a type of func(Handler) bool which reports whether an action must be performed
|
|
|
|
// based on the incoming request.
|
|
|
|
//
|
|
|
|
// See `NewConditionalHandler` for more.
|
|
|
|
// An alias for the `context/Filter`.
|
|
|
|
Filter = context.Filter
|
2019-08-12 11:05:21 +02:00
|
|
|
// A Map is an alias of map[string]interface{}.
|
2017-07-10 17:32:42 +02:00
|
|
|
Map = context.Map
|
2019-08-12 11:05:21 +02:00
|
|
|
// Problem Details for HTTP APIs.
|
|
|
|
// Pass a Problem value to `context.Problem` to
|
|
|
|
// write an "application/problem+json" response.
|
|
|
|
//
|
|
|
|
// Read more at: https://github.com/kataras/iris/wiki/Routing-error-handlers
|
|
|
|
//
|
2019-08-15 09:39:38 +02:00
|
|
|
// It is an alias of the `context#Problem` type.
|
2019-08-12 11:05:21 +02:00
|
|
|
Problem = context.Problem
|
2019-08-15 09:39:38 +02:00
|
|
|
// ProblemOptions the optional settings when server replies with a Problem.
|
|
|
|
// See `Context.Problem` method and `Problem` type for more details.
|
|
|
|
//
|
|
|
|
// It is an alias of the `context#ProblemOptions` type.
|
|
|
|
ProblemOptions = context.ProblemOptions
|
|
|
|
// JSON the optional settings for JSON renderer.
|
|
|
|
//
|
|
|
|
// It is an alias of the `context#JSON` type.
|
|
|
|
JSON = context.JSON
|
2019-08-16 18:18:46 +02:00
|
|
|
// XML the optional settings for XML renderer.
|
|
|
|
//
|
|
|
|
// It is an alias of the `context#XML` type.
|
|
|
|
XML = context.XML
|
2017-07-29 03:27:58 +02:00
|
|
|
// Supervisor is a shortcut of the `host#Supervisor`.
|
|
|
|
// Used to add supervisor configurators on common Runners
|
|
|
|
// without the need of importing the `core/host` package.
|
|
|
|
Supervisor = host.Supervisor
|
2017-08-02 13:31:34 +02:00
|
|
|
|
|
|
|
// Party is just a group joiner of routes which have the same prefix and share same middleware(s) also.
|
|
|
|
// Party could also be named as 'Join' or 'Node' or 'Group' , Party chosen because it is fun.
|
|
|
|
//
|
|
|
|
// Look the `core/router#APIBuilder` for its implementation.
|
|
|
|
//
|
|
|
|
// A shortcut for the `core/router#Party`, useful when `PartyFunc` is being used.
|
2019-07-17 23:53:30 +02:00
|
|
|
Party = router.Party
|
2020-04-17 14:56:36 +02:00
|
|
|
// APIContainer is a wrapper of a common `Party` featured by Dependency Injection.
|
|
|
|
// See `Party.ConfigureContainer` for more.
|
|
|
|
//
|
|
|
|
// A shortcut for the `core/router#APIContainer`.
|
|
|
|
APIContainer = router.APIContainer
|
2020-04-18 21:40:47 +02:00
|
|
|
// ResultHandler describes the function type which should serve the "v" struct value.
|
|
|
|
// See `APIContainer.UseResultHandler`.
|
|
|
|
ResultHandler = hero.ResultHandler
|
2019-07-17 23:53:30 +02:00
|
|
|
// DirOptions contains the optional settings that
|
|
|
|
// `FileServer` and `Party#HandleDir` can use to serve files and assets.
|
|
|
|
// A shortcut for the `router.DirOptions`, useful when `FileServer` or `HandleDir` is being used.
|
2019-06-21 18:43:25 +02:00
|
|
|
DirOptions = router.DirOptions
|
2018-05-21 06:40:43 +02:00
|
|
|
// ExecutionRules gives control to the execution of the route handlers outside of the handlers themselves.
|
|
|
|
// Usage:
|
|
|
|
// Party#SetExecutionRules(ExecutionRules {
|
|
|
|
// Done: ExecutionOptions{Force: true},
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// See `core/router/Party#SetExecutionRules` for more.
|
|
|
|
// Example: https://github.com/kataras/iris/tree/master/_examples/mvc/middleware/without-ctx-next
|
|
|
|
ExecutionRules = router.ExecutionRules
|
|
|
|
// ExecutionOptions is a set of default behaviors that can be changed in order to customize the execution flow of the routes' handlers with ease.
|
|
|
|
//
|
|
|
|
// See `ExecutionRules` and `core/router/Party#SetExecutionRules` for more.
|
|
|
|
ExecutionOptions = router.ExecutionOptions
|
2018-06-02 06:28:40 +02:00
|
|
|
|
|
|
|
// CookieOption is the type of function that is accepted on
|
|
|
|
// context's methods like `SetCookieKV`, `RemoveCookie` and `SetCookie`
|
|
|
|
// as their (last) variadic input argument to amend the end cookie's form.
|
|
|
|
//
|
2019-02-23 06:23:10 +01:00
|
|
|
// Any custom or builtin `CookieOption` is valid,
|
2018-06-02 06:28:40 +02:00
|
|
|
// see `CookiePath`, `CookieCleanPath`, `CookieExpires` and `CookieHTTPOnly` for more.
|
|
|
|
//
|
|
|
|
// An alias for the `context/Context#CookieOption`.
|
|
|
|
CookieOption = context.CookieOption
|
2019-08-03 03:41:09 +02:00
|
|
|
// N is a struct which can be passed on the `Context.Negotiate` method.
|
|
|
|
// It contains fields which should be filled based on the `Context.Negotiation()`
|
|
|
|
// server side values. If no matched mime then its "Other" field will be sent,
|
|
|
|
// which should be a string or []byte.
|
|
|
|
// It completes the `context/context.ContentSelector` interface.
|
|
|
|
//
|
|
|
|
// An alias for the `context/Context#N`.
|
|
|
|
N = context.N
|
2017-07-10 17:32:42 +02:00
|
|
|
)
|