Former-commit-id: 0f0667f7e460dc241f3a8fcca50cc6caf228d081
This commit is contained in:
Gerasimos (Makis) Maropoulos 2017-10-10 05:17:53 +03:00
parent 82b5a1d4ed
commit 7ab607aab2
6 changed files with 12 additions and 16 deletions

View File

@ -471,7 +471,7 @@ type Movie struct {
// simple checks can be added here.
//
// It's just a showcase,
// imagine what possible this opens when you designing a bigger application.
// imagine the potentials this feature gives when designing a bigger application.
//
// This is called where the return value from a controller's method functions
// is type of `Movie`.
@ -700,7 +700,7 @@ func (s *MovieMemoryService) GetAll() []models.Movie {
```go
// file: controllers/movies_controller.go
// file: controllers/movie_controller.go
package controllers
@ -770,7 +770,6 @@ func (c *MovieController) PutBy(id int64) (models.Movie, error) {
// Demo:
// curl -i -X DELETE -u admin:password http://localhost:8080/movies/1
func (c *MovieController) DeleteBy(id int64) interface{} {
// delete the entry from the movies slice.
wasDel := c.Service.DeleteByID(id)
if wasDel {
// and return the deleted movie's ID

View File

@ -1,4 +1,4 @@
// file: controllers/movies_controller.go
// file: controllers/movie_controller.go
package controllers
@ -68,13 +68,12 @@ func (c *MovieController) PutBy(id int64) (models.Movie, error) {
// Demo:
// curl -i -X DELETE -u admin:password http://localhost:8080/movies/1
func (c *MovieController) DeleteBy(id int64) interface{} {
// delete the entry from the movies slice.
wasDel := c.Service.DeleteByID(id)
if wasDel {
// and return the deleted movie's ID
// return the deleted movie's ID
return iris.Map{"deleted": id}
}
// here we can see that a method function can return any of those two types(map or int),
// right here we can see that a method function can return any of those two types(map or int),
// we don't have to specify the return type to a specific type.
return iris.StatusBadRequest
}

View File

@ -20,7 +20,7 @@ func main() {
// Register our controllers.
app.Controller("/hello", new(controllers.HelloController))
// Create our movie service (memory), we will bind it to the movies controller.
// Create our movie service (memory), we will bind it to the movie controller.
service := services.NewMovieServiceFromMemory(datasource.Movies)
app.Controller("/movies", new(controllers.MovieController),

View File

@ -24,7 +24,7 @@ type Movie struct {
// simple checks can be added here.
//
// It's just a showcase,
// imagine what possible this opens when you designing a bigger application.
// imagine the potentials this feature gives when designing a bigger application.
//
// This is called where the return value from a controller's method functions
// is type of `Movie`.

6
faq.md
View File

@ -55,7 +55,7 @@ You can find all type aliases and their original package import statements at th
Iris may have reached version 8, but we're not stopping there. We have many feature ideas on our board that we're anxious to add and other innovative web development solutions that we're planning to build into Iris.
## Can I found a job if I learn how to use Iris?
## Can I find a job if I learn how to use Iris?
Yes, not only because you will learn Golang in the same time, but there are some positions
open for Iris-specific developers the time we speak.
@ -78,6 +78,4 @@ https://github.com/kataras/iris/issues/646
By normal people like you, who help us by donating small or larger amounts of money.
Help this project to continue deliver awesome and unique features with the higher code quality as possible by donating any amount via [PayPal](https://www.paypal.me/kataras)!
[![](https://www.paypalobjects.com/webstatic/paypalme/images/pp_logo_small.png)](https://www.paypal.me/kataras)
Help this project to continue deliver awesome and unique features with the higher code quality as possible by donating any amount via [PayPal](https://www.paypal.me/kataras)!

View File

@ -71,10 +71,10 @@ func (b *binder) lookup(elem reflect.Type) (fields []field.Field) {
matcher := func(elemField reflect.StructField) bool {
// If the controller's field is interface then check
// if the given binded value implements that interface.
// i.e MovieController { service services.MoviesController /* interface */ }
// i.e MovieController { Service services.MoviesController /* interface */ }
// app.Controller("/", new(MovieController),
// services.NewMovieMemoryController(...))
// *MovieMemoryService type
// services.NewMovieMemoryService(...))
// services.NewMovieMemoryService returns a *MovieMemoryService
// that implements the MovieService interface.
if elemField.Type.Kind() == reflect.Interface {
return value.Type().Implements(elemField.Type)