Home > Articles

  • Print
  • + Share This
This chapter is from the book

Q & A

Q. Is it possible to set variables in the routing pattern? I want to set something like /products/:id, where :id is a variable.

A. The http package by default uses ServeMux to handle routing, and neither variables nor regular expressions are supported. Some popular community-created routers offer variables and other features like request and content types. Generally, they integrate with the http package.

Q. I used framework libraries in other languages to create servers. Is anything similar available in Go?

A. Yes. There are framework libraries available in Go. For many cases, however, the http package provides everything needed.

Q. How do I create a HTTPS server?

A. The http package supports creating a server served over HTTPS (TLS) through the ListenAndServeTLS method. This works in the same way as ListenAndServe, but expects certificate and key files to be passed to it.

  • + Share This
  • 🔖 Save To Your Account