We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi,
I've been looking through the documentation to increase the post limit and I can't find anything. Any help would be great! Thanks!
The text was updated successfully, but these errors were encountered:
Hi @teaglin, what you need is: ServerOptions: https://ibm-swift.github.io/Kitura-NIO/Structs/ServerOptions.html for NIO-based or https://github.com/IBM-Swift/Kitura-net/blob/master/Sources/KituraNet/ServerOptions.swift (cannot find it in the API documentation indeed).
ServerOptions
The idea is to create a struct that handle the limits for you:
let sizeResponse: (Int, String) -> (HTTPStatusCode, String)? = { (size, client) in Log.warning("Rejecting request from \(client): Size \(size) too big.") return (.requestTooLong, "{\"error\": \"Request too big\", \"code\": 413}") } let serverOptions = ServerOptions( requestSizeLimit: 1048576, // 1024*1024 = 1MB requestSizeResponseGenerator: sizeResponse) Kitura.addHTTPServer(onPort: 8080, with: router, options: serverOptions)
The sizeResponse closure is used to customize the log and the response code, but it is not mandatory. The requestSizeLimit is whatever limit you want.
sizeResponse
requestSizeLimit
Sorry, something went wrong.
No branches or pull requests
Hi,
I've been looking through the documentation to increase the post limit and I can't find anything. Any help would be great! Thanks!
The text was updated successfully, but these errors were encountered: