Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can the API add the function of defining timeout and define maxbytes #1712

Closed
jiang4869 opened this issue Mar 25, 2022 · 2 comments
Closed

Comments

@jiang4869
Copy link
Contributor

jiang4869 commented Mar 25, 2022

When defining a service in the API, you can set the timeout or maxBytes, just like setting JWT

@server(
    jwt:Auth
    timeout: 1
    maxBytes: 1024
    group: user
)
service user {
    @handler getUser // etst
    get /users/id (request) returns (response)
}

and generate code like

func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
	server.AddRoutes(
		[]rest.Route{
			{
				Method:  http.MethodGet,
				Path:    "/users/id",
				Handler: user.GetUserHandler(serverCtx),
			},
		},
		rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
		rest.WithTimeout(1*time.Second),
                rest.WithMaxBytes(1024),

	)
}
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


When defining a service in the API, you can set the timeout, just like setting JWT

@server(
    jwt:Auth
    timeout: 1
    group: user
)
service user {
    @handler getUser // etst
    get /users/id (request) returns (response)
}

and generate code like

func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
	server.AddRoutes(
		[]rest.Route{
			{
				Method:  http.MethodGet,
				Path:    "/users/id",
				Handler: user.GetUserHandler(serverCtx),
			},
		},
		rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
		rest.WithTimeout(1*time.Second),
	)
}

@jiang4869 jiang4869 changed the title Can the API add the function of defining timeout Can the API add the function of defining timeout and define maxbytes Mar 26, 2022
@jiang4869
Copy link
Contributor Author

#1713 This pull requests solves this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants