mirror of
https://github.com/kataras/iris.git
synced 2025-02-13 04:26:18 +01:00
update to version 8.4.1 ❤️ https://github.com/kataras/iris/blob/master/HISTORY.md#th-07-september-2017--v841
Former-commit-id: 9e5f0a08049b83605aa847b8f51fb856427354a6
This commit is contained in:
parent
fcfc65a7bc
commit
8a9a498316
66
HISTORY.md
66
HISTORY.md
|
@ -18,6 +18,72 @@ Developers are not forced to upgrade if they don't really need it. Upgrade whene
|
||||||
|
|
||||||
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
|
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
|
||||||
|
|
||||||
|
# Th, 07 September 2017 | v8.4.1
|
||||||
|
|
||||||
|
## Routing
|
||||||
|
|
||||||
|
Add a macro type for booleans: `app.Get("/mypath/{paramName:boolean}", myHandler)`.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
+------------------------+
|
||||||
|
| {param:boolean} |
|
||||||
|
+------------------------+
|
||||||
|
bool type
|
||||||
|
only "1" or "t" or "T" or "TRUE" or "true" or "True"
|
||||||
|
or "0" or "f" or "F" or "FALSE" or "false" or "False"
|
||||||
|
```
|
||||||
|
|
||||||
|
Add `context.Params().GetBool(paramName string) (bool, error)` respectfully.
|
||||||
|
|
||||||
|
```go
|
||||||
|
app := iris.New()
|
||||||
|
app.Get("/mypath/{has:boolean}", func(ctx iris.Context){ // <--
|
||||||
|
// boolean first return value
|
||||||
|
// error as second return value
|
||||||
|
//
|
||||||
|
// error will be always nil here because
|
||||||
|
// we use the {has:boolean} so router
|
||||||
|
// makes sure that the parameter is a boolean
|
||||||
|
// otherwise it will return a 404 not found http error code
|
||||||
|
// skipping the call of this handler.
|
||||||
|
has, _ := ctx.Params().GetBool("has") // <--
|
||||||
|
if has {
|
||||||
|
ctx.HTML("<strong>it's true</strong>")
|
||||||
|
}else {
|
||||||
|
ctx.HTML("<strong>it's false</string>")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// [...]
|
||||||
|
```
|
||||||
|
|
||||||
|
## MVC
|
||||||
|
|
||||||
|
Support for boolean method receivers, i.e `GetBy(bool), PostBy(bool)...`.
|
||||||
|
|
||||||
|
|
||||||
|
```go
|
||||||
|
app := iris.New()
|
||||||
|
|
||||||
|
app.Controller("/equality", new(Controller))
|
||||||
|
```
|
||||||
|
|
||||||
|
```go
|
||||||
|
type Controller struct {
|
||||||
|
iris.Controller
|
||||||
|
}
|
||||||
|
|
||||||
|
// handles the "/equality" path.
|
||||||
|
func (c *Controller) Get() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// registers and handles the path: "/equality/{param:boolean}".
|
||||||
|
func (c *Controller) GetBy(is bool) { // <--
|
||||||
|
// [...]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
> Supported types for method functions receivers are: int, int64, bool and string.
|
||||||
|
|
||||||
# Su, 27 August 2017 | v8.4.0
|
# Su, 27 August 2017 | v8.4.0
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ Iris may have reached version 8, but we're not stopping there. We have many feat
|
||||||
### 📑 Table of contents
|
### 📑 Table of contents
|
||||||
|
|
||||||
* [Installation](#-installation)
|
* [Installation](#-installation)
|
||||||
* [Latest changes](https://github.com/kataras/iris/blob/master/HISTORY.md#su-27-august-2017--v840)
|
* [Latest changes](https://github.com/kataras/iris/blob/master/HISTORY.md#th-07-september-2017--v841)
|
||||||
* [Learn](#-learn)
|
* [Learn](#-learn)
|
||||||
* [HTTP Listening](_examples/#http-listening)
|
* [HTTP Listening](_examples/#http-listening)
|
||||||
* [Configuration](_examples/#configuration)
|
* [Configuration](_examples/#configuration)
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
8.4.0:https://github.com/kataras/iris/blob/master/HISTORY.md#su-27-august-2017--v840
|
8.4.1:https://github.com/kataras/iris/blob/master/HISTORY.md#th-07-september-2017--v841
|
|
@ -48,6 +48,13 @@ func main() {
|
||||||
// only numbers (0-9)
|
// only numbers (0-9)
|
||||||
//
|
//
|
||||||
// +------------------------+
|
// +------------------------+
|
||||||
|
// | {param:boolean} |
|
||||||
|
// +------------------------+
|
||||||
|
// bool type
|
||||||
|
// only "1" or "t" or "T" or "TRUE" or "true" or "True"
|
||||||
|
// or "0" or "f" or "F" or "FALSE" or "false" or "False"
|
||||||
|
//
|
||||||
|
// +------------------------+
|
||||||
// | {param:alphabetical} |
|
// | {param:alphabetical} |
|
||||||
// +------------------------+
|
// +------------------------+
|
||||||
// alphabetical/letter type
|
// alphabetical/letter type
|
||||||
|
|
|
@ -107,6 +107,14 @@ func (r RequestParams) GetInt64(key string) (int64, error) {
|
||||||
return r.store.GetInt64(key)
|
return r.store.GetInt64(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetBool returns the user's value as bool, based on its key.
|
||||||
|
// a string which is "1" or "t" or "T" or "TRUE" or "true" or "True"
|
||||||
|
// or "0" or "f" or "F" or "FALSE" or "false" or "False".
|
||||||
|
// Any other value returns an error.
|
||||||
|
func (r RequestParams) GetBool(key string) (bool, error) {
|
||||||
|
return r.store.GetBool(key)
|
||||||
|
}
|
||||||
|
|
||||||
// GetDecoded returns the url-query-decoded user's value based on its key.
|
// GetDecoded returns the url-query-decoded user's value based on its key.
|
||||||
func (r RequestParams) GetDecoded(key string) string {
|
func (r RequestParams) GetDecoded(key string) string {
|
||||||
return DecodeQuery(DecodeQuery(r.Get(key)))
|
return DecodeQuery(DecodeQuery(r.Get(key)))
|
||||||
|
@ -1368,6 +1376,10 @@ func (ctx *context) Redirect(urlToRedirect string, statusHeader ...int) {
|
||||||
|
|
||||||
// get the previous status code given by the end-developer.
|
// get the previous status code given by the end-developer.
|
||||||
status := ctx.GetStatusCode()
|
status := ctx.GetStatusCode()
|
||||||
|
if status < 300 { // the previous is not a RCF-valid redirect status.
|
||||||
|
status = 0
|
||||||
|
}
|
||||||
|
|
||||||
if len(statusHeader) > 0 {
|
if len(statusHeader) > 0 {
|
||||||
// check if status code is passed via receivers.
|
// check if status code is passed via receivers.
|
||||||
if s := statusHeader[0]; s > 0 {
|
if s := statusHeader[0]; s > 0 {
|
||||||
|
|
|
@ -254,7 +254,12 @@ func (su *Supervisor) ListenAndServeTLS(certFile string, keyFile string) error {
|
||||||
// manually inserted as pre-go 1.9 for any case.
|
// manually inserted as pre-go 1.9 for any case.
|
||||||
cfg.NextProtos = []string{"h2", "http/1.1"}
|
cfg.NextProtos = []string{"h2", "http/1.1"}
|
||||||
su.Server.TLSConfig = cfg
|
su.Server.TLSConfig = cfg
|
||||||
return su.ListenAndServe()
|
|
||||||
|
// It does nothing more than the su.Server.ListenAndServeTLS anymore.
|
||||||
|
// - no hurt if we let it as it is
|
||||||
|
// - no problem if we remove it as well
|
||||||
|
// but let's comment this as proposed, fewer code is better:
|
||||||
|
// return su.ListenAndServe()
|
||||||
}
|
}
|
||||||
|
|
||||||
if su.Server.TLSConfig == nil {
|
if su.Server.TLSConfig == nil {
|
||||||
|
|
|
@ -181,6 +181,14 @@ func (r *Store) GetInt64(key string) (int64, error) {
|
||||||
return strconv.ParseInt(r.GetString(key), 10, 64)
|
return strconv.ParseInt(r.GetString(key), 10, 64)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetBool returns the user's value as bool, based on its key.
|
||||||
|
// a string which is "1" or "t" or "T" or "TRUE" or "true" or "True"
|
||||||
|
// or "0" or "f" or "F" or "FALSE" or "false" or "False".
|
||||||
|
// Any other value returns an error.
|
||||||
|
func (r *Store) GetBool(key string) (bool, error) {
|
||||||
|
return strconv.ParseBool(key)
|
||||||
|
}
|
||||||
|
|
||||||
// Remove deletes an entry linked to that "key",
|
// Remove deletes an entry linked to that "key",
|
||||||
// returns true if an entry is actually removed.
|
// returns true if an entry is actually removed.
|
||||||
func (r *Store) Remove(key string) bool {
|
func (r *Store) Remove(key string) bool {
|
||||||
|
|
|
@ -18,13 +18,18 @@ const (
|
||||||
// Declaration: /mypath/{myparam:string} or /mypath{myparam}
|
// Declaration: /mypath/{myparam:string} or /mypath{myparam}
|
||||||
ParamTypeString
|
ParamTypeString
|
||||||
// ParamTypeInt is the integer, a number type.
|
// ParamTypeInt is the integer, a number type.
|
||||||
// Allows only numbers (0-9)
|
// Allows only possitive numbers (0-9)
|
||||||
// Declaration: /mypath/{myparam:int}
|
// Declaration: /mypath/{myparam:int}
|
||||||
ParamTypeInt
|
ParamTypeInt
|
||||||
// ParamTypeLong is the integer, a number type.
|
// ParamTypeLong is the integer, a number type.
|
||||||
// Allows only numbers (0-9)
|
// Allows only possitive numbers (0-9)
|
||||||
// Declaration: /mypath/{myparam:long}
|
// Declaration: /mypath/{myparam:long}
|
||||||
ParamTypeLong
|
ParamTypeLong
|
||||||
|
// ParamTypeBoolean is the bool type.
|
||||||
|
// Allows only "1" or "t" or "T" or "TRUE" or "true" or "True"
|
||||||
|
// or "0" or "f" or "F" or "FALSE" or "false" or "False".
|
||||||
|
// Declaration: /mypath/{myparam:boolean}
|
||||||
|
ParamTypeBoolean
|
||||||
// ParamTypeAlphabetical is the alphabetical/letter type type.
|
// ParamTypeAlphabetical is the alphabetical/letter type type.
|
||||||
// Allows letters only (upper or lowercase)
|
// Allows letters only (upper or lowercase)
|
||||||
// Declaration: /mypath/{myparam:alphabetical}
|
// Declaration: /mypath/{myparam:alphabetical}
|
||||||
|
@ -49,6 +54,7 @@ var paramTypes = map[string]ParamType{
|
||||||
"string": ParamTypeString,
|
"string": ParamTypeString,
|
||||||
"int": ParamTypeInt,
|
"int": ParamTypeInt,
|
||||||
"long": ParamTypeLong,
|
"long": ParamTypeLong,
|
||||||
|
"boolean": ParamTypeBoolean,
|
||||||
"alphabetical": ParamTypeAlphabetical,
|
"alphabetical": ParamTypeAlphabetical,
|
||||||
"file": ParamTypeFile,
|
"file": ParamTypeFile,
|
||||||
"path": ParamTypePath,
|
"path": ParamTypePath,
|
||||||
|
|
|
@ -131,6 +131,13 @@ func TestParseParam(t *testing.T) {
|
||||||
Type: ast.ParamTypeLong,
|
Type: ast.ParamTypeLong,
|
||||||
ErrorCode: 404,
|
ErrorCode: 404,
|
||||||
}}, // 8
|
}}, // 8
|
||||||
|
{true,
|
||||||
|
ast.ParamStatement{
|
||||||
|
Src: "{has:boolean else 404}",
|
||||||
|
Name: "has",
|
||||||
|
Type: ast.ParamTypeBoolean,
|
||||||
|
ErrorCode: 404,
|
||||||
|
}}, // 9
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strconv"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"github.com/kataras/iris/core/router/macro/interpreter/ast"
|
"github.com/kataras/iris/core/router/macro/interpreter/ast"
|
||||||
|
@ -208,17 +209,23 @@ func (m *Macro) getFunc(funcName string) ParamEvaluatorBuilder {
|
||||||
|
|
||||||
// Map contains the default macros mapped to their types.
|
// Map contains the default macros mapped to their types.
|
||||||
// This is the manager which is used by the caller to register custom
|
// This is the manager which is used by the caller to register custom
|
||||||
// parameter functions per param-type (String, Int, Long, Alphabetical, File, Path).
|
// parameter functions per param-type (String, Int, Long, Boolean, Alphabetical, File, Path).
|
||||||
type Map struct {
|
type Map struct {
|
||||||
// string type
|
// string type
|
||||||
// anything
|
// anything
|
||||||
String *Macro
|
String *Macro
|
||||||
// int type
|
// uint type
|
||||||
// only numbers (0-9)
|
// only possitive numbers (+0-9)
|
||||||
|
// it could be uint/uint32 but we keep int for simplicity
|
||||||
Int *Macro
|
Int *Macro
|
||||||
// long an int64 type
|
// long an int64 type
|
||||||
// only numbers (0-9)
|
// only possitive numbers (+0-9)
|
||||||
|
// it could be uint64 but we keep int64 for simplicity
|
||||||
Long *Macro
|
Long *Macro
|
||||||
|
// boolean as bool type
|
||||||
|
// a string which is "1" or "t" or "T" or "TRUE" or "true" or "True"
|
||||||
|
// or "0" or "f" or "F" or "FALSE" or "false" or "False".
|
||||||
|
Boolean *Macro
|
||||||
// alphabetical/letter type
|
// alphabetical/letter type
|
||||||
// letters only (upper or lowercase)
|
// letters only (upper or lowercase)
|
||||||
Alphabetical *Macro
|
Alphabetical *Macro
|
||||||
|
@ -245,6 +252,12 @@ func NewMap() *Map {
|
||||||
String: newMacro(func(string) bool { return true }),
|
String: newMacro(func(string) bool { return true }),
|
||||||
Int: newMacro(MustNewEvaluatorFromRegexp("^[0-9]+$")),
|
Int: newMacro(MustNewEvaluatorFromRegexp("^[0-9]+$")),
|
||||||
Long: newMacro(MustNewEvaluatorFromRegexp("^[0-9]+$")),
|
Long: newMacro(MustNewEvaluatorFromRegexp("^[0-9]+$")),
|
||||||
|
Boolean: newMacro(func(paramValue string) bool {
|
||||||
|
// a simple if statement is faster than regex ^(true|false|True|False|t|0|f|FALSE|TRUE)$
|
||||||
|
// in this case.
|
||||||
|
_, err := strconv.ParseBool(paramValue)
|
||||||
|
return err == nil
|
||||||
|
}),
|
||||||
Alphabetical: newMacro(MustNewEvaluatorFromRegexp("^[a-zA-Z ]+$")),
|
Alphabetical: newMacro(MustNewEvaluatorFromRegexp("^[a-zA-Z ]+$")),
|
||||||
File: newMacro(MustNewEvaluatorFromRegexp("^[a-zA-Z0-9_.-]*$")),
|
File: newMacro(MustNewEvaluatorFromRegexp("^[a-zA-Z0-9_.-]*$")),
|
||||||
// it allows everything, we have String and Path as different
|
// it allows everything, we have String and Path as different
|
||||||
|
@ -265,6 +278,8 @@ func (m *Map) Lookup(typ ast.ParamType) *Macro {
|
||||||
return m.Int
|
return m.Int
|
||||||
case ast.ParamTypeLong:
|
case ast.ParamTypeLong:
|
||||||
return m.Long
|
return m.Long
|
||||||
|
case ast.ParamTypeBoolean:
|
||||||
|
return m.Boolean
|
||||||
case ast.ParamTypeAlphabetical:
|
case ast.ParamTypeAlphabetical:
|
||||||
return m.Alphabetical
|
return m.Alphabetical
|
||||||
case ast.ParamTypeFile:
|
case ast.ParamTypeFile:
|
||||||
|
|
14
doc.go
14
doc.go
|
@ -832,7 +832,6 @@ Register one or more relative paths and able to get path parameters, i.e
|
||||||
- `func(*Controller) PostProfileFollowers()` - `POST:/user/profile/followers`
|
- `func(*Controller) PostProfileFollowers()` - `POST:/user/profile/followers`
|
||||||
- `func(*Controller) GetBy(id int64)` - `GET:/user/{param:long}`
|
- `func(*Controller) GetBy(id int64)` - `GET:/user/{param:long}`
|
||||||
- `func(*Controller) PostBy(id int64)` - `POST:/user/{param:long}`
|
- `func(*Controller) PostBy(id int64)` - `POST:/user/{param:long}`
|
||||||
|
|
||||||
If `app.Controller("/profile", new(profile.Controller))`
|
If `app.Controller("/profile", new(profile.Controller))`
|
||||||
|
|
||||||
- `func(*Controller) GetBy(username string)` - `GET:/profile/{param:string}`
|
- `func(*Controller) GetBy(username string)` - `GET:/profile/{param:string}`
|
||||||
|
@ -841,6 +840,12 @@ Register one or more relative paths and able to get path parameters, i.e
|
||||||
|
|
||||||
- `func(*Controller) GetByWildard(path string)` - `GET:/assets/{param:path}`
|
- `func(*Controller) GetByWildard(path string)` - `GET:/assets/{param:path}`
|
||||||
|
|
||||||
|
If `app.Controller("/equality", new(profile.Equality))`
|
||||||
|
|
||||||
|
- `func(*Controller) GetBy(is bool)` - `GET:/equality/{param:boolean}`
|
||||||
|
|
||||||
|
Supported types for method functions receivers: int, int64, bool and string.
|
||||||
|
|
||||||
|
|
||||||
Using Iris MVC for code reuse
|
Using Iris MVC for code reuse
|
||||||
|
|
||||||
|
@ -901,6 +906,13 @@ Standard macro types for parameters:
|
||||||
int64 type
|
int64 type
|
||||||
only numbers (0-9)
|
only numbers (0-9)
|
||||||
|
|
||||||
|
+------------------------+
|
||||||
|
| {param:boolean} |
|
||||||
|
+------------------------+
|
||||||
|
bool type
|
||||||
|
only "1" or "t" or "T" or "TRUE" or "true" or "True"
|
||||||
|
or "0" or "f" or "F" or "FALSE" or "false" or "False"
|
||||||
|
|
||||||
+------------------------+
|
+------------------------+
|
||||||
| {param:alphabetical} |
|
| {param:alphabetical} |
|
||||||
+------------------------+
|
+------------------------+
|
||||||
|
|
2
iris.go
2
iris.go
|
@ -32,7 +32,7 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Version is the current version number of the Iris Web Framework.
|
// Version is the current version number of the Iris Web Framework.
|
||||||
Version = "8.4.0"
|
Version = "8.4.1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HTTP status codes as registered with IANA.
|
// HTTP status codes as registered with IANA.
|
||||||
|
|
|
@ -53,6 +53,13 @@ func resolveCaller(p pathInfo) callerFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if p.ParamType == paramTypeBoolean {
|
||||||
|
return func(ctx context.Context, f interface{}) {
|
||||||
|
paramValue, _ := ctx.Params().GetBool(paramName)
|
||||||
|
f.(func(bool))(paramValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// else it's string or path, both of them are simple strings.
|
// else it's string or path, both of them are simple strings.
|
||||||
return func(ctx context.Context, f interface{}) {
|
return func(ctx context.Context, f interface{}) {
|
||||||
paramValue := ctx.Params().Get(paramName)
|
paramValue := ctx.Params().Get(paramName)
|
||||||
|
|
|
@ -22,6 +22,7 @@ type pathInfo struct {
|
||||||
const (
|
const (
|
||||||
paramTypeInt = "int"
|
paramTypeInt = "int"
|
||||||
paramTypeLong = "long"
|
paramTypeLong = "long"
|
||||||
|
paramTypeBoolean = "boolean"
|
||||||
paramTypeString = "string"
|
paramTypeString = "string"
|
||||||
paramTypePath = "path"
|
paramTypePath = "path"
|
||||||
)
|
)
|
||||||
|
@ -29,6 +30,7 @@ const (
|
||||||
var macroTypes = map[string]string{
|
var macroTypes = map[string]string{
|
||||||
"int": paramTypeInt,
|
"int": paramTypeInt,
|
||||||
"int64": paramTypeLong,
|
"int64": paramTypeLong,
|
||||||
|
"bool": paramTypeBoolean,
|
||||||
"string": paramTypeString,
|
"string": paramTypeString,
|
||||||
// there is "path" param type but it's being captured "on-air"
|
// there is "path" param type but it's being captured "on-air"
|
||||||
// "file" param type is not supported by the current implementation, yet
|
// "file" param type is not supported by the current implementation, yet
|
||||||
|
@ -71,7 +73,7 @@ func resolveRelativePath(info FuncInfo) (p pathInfo, ok bool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// int and string are supported.
|
// int, int64, bool and string are supported.
|
||||||
// as there is no way to get the parameter name
|
// as there is no way to get the parameter name
|
||||||
// we will use the "param" everywhere.
|
// we will use the "param" everywhere.
|
||||||
suffix := fmt.Sprintf("/{%s:%s}", paramName, paramType)
|
suffix := fmt.Sprintf("/{%s:%s}", paramName, paramType)
|
||||||
|
|
|
@ -445,14 +445,16 @@ func (c *testControllerRelPathFromFunc) EndRequest(ctx context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *testControllerRelPathFromFunc) Get() {}
|
func (c *testControllerRelPathFromFunc) Get() {}
|
||||||
|
func (c *testControllerRelPathFromFunc) GetBy(int64) {}
|
||||||
|
func (c *testControllerRelPathFromFunc) GetByWildcard(string) {}
|
||||||
|
|
||||||
func (c *testControllerRelPathFromFunc) GetLogin() {}
|
func (c *testControllerRelPathFromFunc) GetLogin() {}
|
||||||
func (c *testControllerRelPathFromFunc) PostLogin() {}
|
func (c *testControllerRelPathFromFunc) PostLogin() {}
|
||||||
|
|
||||||
func (c *testControllerRelPathFromFunc) GetAdminLogin() {}
|
func (c *testControllerRelPathFromFunc) GetAdminLogin() {}
|
||||||
func (c *testControllerRelPathFromFunc) PutSomethingIntoThis() {}
|
|
||||||
func (c *testControllerRelPathFromFunc) GetBy(int64) {}
|
|
||||||
|
|
||||||
func (c *testControllerRelPathFromFunc) GetByWildcard(string) {}
|
func (c *testControllerRelPathFromFunc) PutSomethingIntoThis() {}
|
||||||
|
func (c *testControllerRelPathFromFunc) GetSomethingBy(bool) {}
|
||||||
|
|
||||||
func TestControllerRelPathFromFunc(t *testing.T) {
|
func TestControllerRelPathFromFunc(t *testing.T) {
|
||||||
app := iris.New()
|
app := iris.New()
|
||||||
|
@ -461,6 +463,16 @@ func TestControllerRelPathFromFunc(t *testing.T) {
|
||||||
e := httptest.New(t, app)
|
e := httptest.New(t, app)
|
||||||
e.GET("/").Expect().Status(httptest.StatusOK).
|
e.GET("/").Expect().Status(httptest.StatusOK).
|
||||||
Body().Equal("GET:/")
|
Body().Equal("GET:/")
|
||||||
|
|
||||||
|
e.GET("/42").Expect().Status(httptest.StatusOK).
|
||||||
|
Body().Equal("GET:/42")
|
||||||
|
e.GET("/something/true").Expect().Status(httptest.StatusOK).
|
||||||
|
Body().Equal("GET:/something/true")
|
||||||
|
e.GET("/something/false").Expect().Status(httptest.StatusOK).
|
||||||
|
Body().Equal("GET:/something/false")
|
||||||
|
e.GET("/something/truee").Expect().Status(httptest.StatusNotFound)
|
||||||
|
e.GET("/something/falsee").Expect().Status(httptest.StatusNotFound)
|
||||||
|
|
||||||
e.GET("/login").Expect().Status(httptest.StatusOK).
|
e.GET("/login").Expect().Status(httptest.StatusOK).
|
||||||
Body().Equal("GET:/login")
|
Body().Equal("GET:/login")
|
||||||
e.POST("/login").Expect().Status(httptest.StatusOK).
|
e.POST("/login").Expect().Status(httptest.StatusOK).
|
||||||
|
|
Loading…
Reference in New Issue
Block a user