mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 15:55:54 +01:00
Update README.md
This commit is contained in:
parent
965c945a7a
commit
400b6ab69a
25
README.md
25
README.md
@ -103,13 +103,21 @@ type
|
|||||||
[MVCHTTPMethod([httpGET])]
|
[MVCHTTPMethod([httpGET])]
|
||||||
procedure GetUsers(CTX: TWebContext);
|
procedure GetUsers(CTX: TWebContext);
|
||||||
|
|
||||||
//The following action will be with a POST or PUT request like the following
|
//The following action will be with a PUT request like the following
|
||||||
//http://myserver.com/users/3
|
//http://myserver.com/users/3
|
||||||
//and in the request body there should be a serialized TUser
|
//and in the request body there should be a serialized TUser
|
||||||
[MVCPath('/($id)')]
|
[MVCPath('/($id)')]
|
||||||
[MVCProduce('application/json')]
|
[MVCProduce('application/json')]
|
||||||
[MVCHTTPMethod([httPOST, httpPUT])]
|
[MVCHTTPMethod([httpPUT])]
|
||||||
procedure UpdateOrCreateUser(CTX: TWebContext);
|
procedure UpdateUser(CTX: TWebContext);
|
||||||
|
|
||||||
|
//The following action will respond to a POST request like the following
|
||||||
|
//http://myserver.com/users
|
||||||
|
//and in the request body there should be the new user to create as json
|
||||||
|
[MVCPath]
|
||||||
|
[MVCProduce('application/json')]
|
||||||
|
[MVCHTTPMethod([httpPOST])]
|
||||||
|
procedure CreateUser(CTX: TWebContext);
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -128,7 +136,7 @@ begin
|
|||||||
Render(User);
|
Render(User);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUsersController.UpdateOrCreateUser(CTX: TWebContext);
|
procedure TUsersController.UpdateUser(CTX: TWebContext);
|
||||||
var
|
var
|
||||||
User: TUser;
|
User: TUser;
|
||||||
begin
|
begin
|
||||||
@ -137,6 +145,15 @@ begin
|
|||||||
Render(User);
|
Render(User);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TUsersController.CreateUser(CTX: TWebContext);
|
||||||
|
var
|
||||||
|
User: TUser;
|
||||||
|
begin
|
||||||
|
User := CTX.Request.BodyAs<TUser>;
|
||||||
|
CreateUser(User);
|
||||||
|
Render(User);
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user