A native Go webserver that calculates the fibonacci sequence recursively... by sending HTTP requests to itself! All in under 40 lines of code.
- Build and execute the file in one command with
go run main.go(useCtrl+Cto stop the server) - That's it. Now you can send an HTTP
GETrequest to the server likecurl localhost:8080/fibonacci/n, wherenis the fibonacci number you want to calculate.- eg. if you send
curl localhost:8080/fibonacci/11, you'll get back{"ans":89}, which is indeed the correct answer for fib(11)!
- eg. if you send