mirror of
https://github.com/kataras/iris.git
synced 2025-02-13 04:26:18 +01:00
add PartyFunc and gofmt -s -w . 🔷
Former-commit-id: a3809498a45140d691f3f235ad9cb25239d495a2
This commit is contained in:
parent
351f099ad6
commit
9143ccec6e
|
@ -15,7 +15,8 @@ after_script:
|
||||||
- cd ./_examples
|
- cd ./_examples
|
||||||
- go get ./...
|
- go get ./...
|
||||||
- go test -v -cover ./...
|
- go test -v -cover ./...
|
||||||
|
- cd ../
|
||||||
# typescript examples
|
# typescript examples
|
||||||
- cd ../../typescript/_examples
|
- cd ./typescript/_examples
|
||||||
- go get ./...
|
- go get ./...
|
||||||
- go test -v -cover ./...
|
- go test -v -cover ./...
|
|
@ -41,6 +41,12 @@ type ResponseRecorder struct {
|
||||||
|
|
||||||
var _ ResponseWriter = &ResponseRecorder{}
|
var _ ResponseWriter = &ResponseRecorder{}
|
||||||
|
|
||||||
|
// Naive returns the simple, underline and original http.ResponseWriter
|
||||||
|
// that backends this response writer.
|
||||||
|
func (w *ResponseRecorder) Naive() http.ResponseWriter {
|
||||||
|
return w.ResponseWriter.Naive()
|
||||||
|
}
|
||||||
|
|
||||||
// BeginRecord accepts its parent ResponseWriter and
|
// BeginRecord accepts its parent ResponseWriter and
|
||||||
// prepares itself, the response recorder, to record and send response to the client.
|
// prepares itself, the response recorder, to record and send response to the client.
|
||||||
func (w *ResponseRecorder) BeginRecord(underline ResponseWriter) {
|
func (w *ResponseRecorder) BeginRecord(underline ResponseWriter) {
|
||||||
|
|
|
@ -28,6 +28,10 @@ type ResponseWriter interface {
|
||||||
http.CloseNotifier
|
http.CloseNotifier
|
||||||
http.Pusher
|
http.Pusher
|
||||||
|
|
||||||
|
// Naive returns the simple, underline and original http.ResponseWriter
|
||||||
|
// that backends this response writer.
|
||||||
|
Naive() http.ResponseWriter
|
||||||
|
|
||||||
// BeginResponse receives an http.ResponseWriter
|
// BeginResponse receives an http.ResponseWriter
|
||||||
// and initialize or reset the response writer's field's values.
|
// and initialize or reset the response writer's field's values.
|
||||||
BeginResponse(http.ResponseWriter)
|
BeginResponse(http.ResponseWriter)
|
||||||
|
@ -117,6 +121,12 @@ const (
|
||||||
StatusCodeWritten = 0
|
StatusCodeWritten = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Naive returns the simple, underline and original http.ResponseWriter
|
||||||
|
// that backends this response writer.
|
||||||
|
func (w *responseWriter) Naive() http.ResponseWriter {
|
||||||
|
return w.ResponseWriter
|
||||||
|
}
|
||||||
|
|
||||||
// BeginResponse receives an http.ResponseWriter
|
// BeginResponse receives an http.ResponseWriter
|
||||||
// and initialize or reset the response writer's field's values.
|
// and initialize or reset the response writer's field's values.
|
||||||
func (w *responseWriter) BeginResponse(underline http.ResponseWriter) {
|
func (w *responseWriter) BeginResponse(underline http.ResponseWriter) {
|
||||||
|
|
|
@ -215,6 +215,28 @@ func (rb *APIBuilder) Party(relativePath string, handlers ...context.Handler) Pa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PartyFunc same as `Party`, groups routes that share a base path or/and same handlers.
|
||||||
|
// However this function accepts a function that receives this created Party instead.
|
||||||
|
// Returns the Party in order the caller to be able to use this created Party to continue the
|
||||||
|
// top-bottom routes "tree".
|
||||||
|
//
|
||||||
|
// Note: `iris#Party` and `core/router#Party` describes the exactly same interface.
|
||||||
|
//
|
||||||
|
// Usage:
|
||||||
|
// app.PartyFunc("/users", func(u iris.Party){
|
||||||
|
// u.Use(authMiddleware, logMiddleware)
|
||||||
|
// u.Get("/", getAllUsers)
|
||||||
|
// u.Post("/", createOrUpdateUser)
|
||||||
|
// u.Delete("/", deleteUser)
|
||||||
|
// })
|
||||||
|
//
|
||||||
|
// Look `Party` for more.
|
||||||
|
func (rb *APIBuilder) PartyFunc(relativePath string, partyBuilderFunc func(p Party)) Party {
|
||||||
|
p := rb.Party(relativePath)
|
||||||
|
partyBuilderFunc(p)
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
// Subdomain returns a new party which is responsible to register routes to
|
// Subdomain returns a new party which is responsible to register routes to
|
||||||
// this specific "subdomain".
|
// this specific "subdomain".
|
||||||
//
|
//
|
||||||
|
|
|
@ -2,7 +2,9 @@ package router
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/kataras/iris/context"
|
"github.com/kataras/iris/context"
|
||||||
) // Party is here to separate the concept of
|
)
|
||||||
|
|
||||||
|
// Party is here to separate the concept of
|
||||||
// api builder and the sub api builder.
|
// api builder and the sub api builder.
|
||||||
|
|
||||||
// Party is just a group joiner of routes which have the same prefix and share same middleware(s) also.
|
// Party is just a group joiner of routes which have the same prefix and share same middleware(s) also.
|
||||||
|
@ -12,6 +14,23 @@ import (
|
||||||
type Party interface {
|
type Party interface {
|
||||||
// Party creates and returns a new child Party with the following features.
|
// Party creates and returns a new child Party with the following features.
|
||||||
Party(relativePath string, middleware ...context.Handler) Party
|
Party(relativePath string, middleware ...context.Handler) Party
|
||||||
|
// PartyFunc same as `Party`, groups routes that share a base path or/and same handlers.
|
||||||
|
// However this function accepts a function that receives this created Party instead.
|
||||||
|
// Returns the Party in order the caller to be able to use this created Party to continue the
|
||||||
|
// top-bottom routes "tree".
|
||||||
|
//
|
||||||
|
// Note: `iris#Party` and `core/router#Party` describes the exactly same interface.
|
||||||
|
//
|
||||||
|
// Usage:
|
||||||
|
// app.PartyFunc("/users", func(u iris.Party){
|
||||||
|
// u.Use(authMiddleware, logMiddleware)
|
||||||
|
// u.Get("/", getAllUsers)
|
||||||
|
// u.Post("/", createOrUpdateUser)
|
||||||
|
// u.Delete("/", deleteUser)
|
||||||
|
// })
|
||||||
|
//
|
||||||
|
// Look `Party` for more.
|
||||||
|
PartyFunc(relativePath string, partyBuilderFunc func(p Party)) Party
|
||||||
// Subdomain returns a new party which is responsible to register routes to
|
// Subdomain returns a new party which is responsible to register routes to
|
||||||
// this specific "subdomain".
|
// this specific "subdomain".
|
||||||
//
|
//
|
||||||
|
|
7
iris.go
7
iris.go
|
@ -276,6 +276,13 @@ func (app *Application) View(writer io.Writer, filename string, layout string, b
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// 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.
|
||||||
|
Party router.Party
|
||||||
// LimitRequestBodySize is a middleware which sets a request body size limit
|
// LimitRequestBodySize is a middleware which sets a request body size limit
|
||||||
// for all next handlers in the chain.
|
// for all next handlers in the chain.
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package redis
|
package redis
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/kataras/iris/sessions/sessiondb/redis/service"
|
"github.com/kataras/iris/sessions/sessiondb/redis/service"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user