| 1 | module fasthttp |
| 2 | |
| 3 | pub struct Server { |
| 4 | pub: |
| 5 | port int = 3000 |
| 6 | max_request_buffer_size int = 8192 |
| 7 | mut: |
| 8 | request_handler fn (fasthttp.HttpRequest) !fasthttp.HttpResponse @[required] |
| 9 | } |
| 10 | |
| 11 | // new_server creates and initializes a new Server instance. |
| 12 | pub fn new_server(config ServerConfig) !&Server { |
| 13 | mut server := &Server{ |
| 14 | port: config.port |
| 15 | max_request_buffer_size: config.max_request_buffer_size |
| 16 | request_handler: config.handler |
| 17 | } |
| 18 | |
| 19 | return server |
| 20 | } |
| 21 | |
| 22 | // run starts the server and begins listening for incoming connections. |
| 23 | pub fn (mut server Server) run() ! { |
| 24 | println('TODO: implement fasthttp.Server.run on windows') |
| 25 | } |
| 26 | |