How to create a route with both GET and POST method ? #79
-
In Grapevine V4, i can do that: [RestRoute(PathInfo = @"/")]
public IHttpContext ROOT(IHttpContext context)
{
context.Response.SendResponse(Encoding.UTF8.GetBytes("Welcome to Grapevine"));
return context;
} |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
I saw this article: https://scottoffen.github.io/grapevine/docs/routes
Hope it helps. |
Beta Was this translation helpful? Give feedback.
-
Thank you very much. |
Beta Was this translation helpful? Give feedback.
-
You can also use multiple [RestRoute("Get", "/hello")]
[RestRoute("Post", "/hello")]
public async Task HelloWorld(IHttpContext context)
{
await context.Response.SendResponseAsync($"Hello, world!");
} However, you would have to differentiate in the method if you want the behavior to change depending on whether the method is |
Beta Was this translation helpful? Give feedback.
-
Thanks, An other question: I am building a server on my PC (IP address of my PC is: 192.168.100.92) as:
but when trying access to http://127.0.0.1:1122/api/test or http://192.168.100.92:1122/api/test i get the result is: only when access to http://localhost:1122/api/test i get the corect result: How to solve this problem ? |
Beta Was this translation helpful? Give feedback.
-
Oh, |
Beta Was this translation helpful? Give feedback.
You can also use multiple
Route
attributes on the method.However, you would have to differentiate in the method if you want the behavior to change depending on whether the method is
POST
orGET
.