minor - remove prego1.9 import paths for context.Context to not comfuse users

Gerasimos (Makis) Maropoulos 2019-08-11 14:52:57 +03:00
parent 9b9d3e24db
commit 0002a162cc
No known key found for this signature in database
GPG Key ID: F169457BBDA4ACF4
5 changed files with 14 additions and 14 deletions

@ -29,7 +29,7 @@ type DirOptions struct {
ShowList bool
// If `ShowList` is true then this function will be used instead
// of the default one to show the list of files of a current requested directory(dir).
DirList func(ctx context.Context, dirName string, dir http.File) error
DirList func(ctx iris.Context, dirName string, dir http.File) error
// When embedded.
Asset func(name string) ([]byte, error)
@ -37,7 +37,7 @@ type DirOptions struct {
AssetNames func() []string
// Optional validator that loops through each found requested resource.
AssetValidator func(ctx context.Context, name string) bool
AssetValidator func(ctx iris.Context, name string) bool
}
```

2
MVC.md

@ -140,7 +140,7 @@ Where `mvc.Result` is a `hero.Result` type alias, which is this interface one:
```go
type Result interface {
// Dispatch should sends the response to the context's response writer.
Dispatch(ctx context.Context)
Dispatch(ctx iris.Context)
}
```

@ -180,7 +180,7 @@ type Context interface {
// Next calls all the next handler from the handlers chain,
// it should be used inside a middleware.
//
// Note: Custom context should override this method in order to be able to pass its own context.Context implementation.
// Note: Custom context should override this method in order to be able to pass its own iris.Context implementation.
Next()
// NextOr checks if chain has a next handler, if so then it executes it
// otherwise it sets a new chain assigned to this Context based on the given handler(s)
@ -514,7 +514,7 @@ type Context interface {
// to be executed. Next handlers are being executed on iris because you can alt the
// error code and change it to a more specific one, i.e
// users := app.Party("/users")
// users.Done(func(ctx context.Context){ if ctx.StatusCode() == 400 { /* custom error code for /users */ }})
// users.Done(func(ctx iris.Context){ if ctx.StatusCode() == 400 { /* custom error code for /users */ }})
NotFound()
// +------------------------------------------------------------+

@ -33,7 +33,7 @@ func internalServerError(ctx iris.Context) {
ctx.WriteString("Oups something went wrong, try again")
}
func index(ctx context.Context) {
func index(ctx iris.Context) {
ctx.View("index.html")
}
```

@ -25,14 +25,14 @@ import (
// 2.
// Create your own custom Context, put any fields you'll need.
type MyContext struct {
// Embed the `context.Context` -
// Embed the `iris.Context` -
// It's totally optional but you will need this if you
// don't want to override all the context's methods!
context.Context
iris.Context
}
// Optionally: validate MyContext implements context.Context on compile-time.
var _ context.Context = &MyContext{}
// Optionally: validate MyContext implements iris.Context on compile-time.
var _ iris.Context = &MyContext{}
// 3.
func (ctx *MyContext) Do(handlers context.Handlers) {
@ -59,7 +59,7 @@ func main() {
app := iris.New()
// 4.
app.ContextPool.Attach(func() context.Context {
app.ContextPool.Attach(func() iris.Context {
return &MyContext{
// If you use the embedded Context,
// call the `context.NewContext` to create one:
@ -72,7 +72,7 @@ func main() {
// Register your route, as you normally do
app.Handle("GET", "/", recordWhichContextForExample,
func(ctx context.Context) {
func(ctx iris.Context) {
// use the context's overridden HTML method.
ctx.HTML("<h1> Hello from my custom context's HTML! </h1>")
})
@ -81,7 +81,7 @@ func main() {
// MyContext.Context embedded default context
// when MyContext is not directly define the View function by itself.
app.Handle("GET", "/hi/{firstname:alphabetical}",recordWhichContextForExample,
func(ctx context.Context) {
func(ctx iris.Context) {
firstname := ctx.Values().GetString("firstname")
ctx.ViewData("firstname", firstname)
@ -94,7 +94,7 @@ func main() {
}
// Should always print "($PATH) Handler is executing from 'MyContext'"
func recordWhichContextForExample(ctx context.Context) {
func recordWhichContextForExample(ctx iris.Context) {
ctx.Application().Logger().Infof("(%s) Handler is executing from: '%s'",
ctx.Path(), reflect.TypeOf(ctx).Elem().Name())