Skip to main content

Configure your HTTP servers

With gosoline, you have flexibility in how you define and run your HTTP servers. In this guide, you'll learn multiple ways to do this, so you can choose the option that best meet your needs.

Default HTTP Server

To configure and run a single, default HTTP server, configure your server in config.dist.yml:

httpserver:
default:
port: 8080

Then, run your server, for example in main.go:

application.RunHttpDefaultServer(definer)

Multiple HTTP Servers

To configure and run multiple servers, configure your servers in config.dist.yml:

httpserver:
public:
port: 8080
private:
port: 8090

Then, run your servers with their own definers, for example in main.go:

application.RunHttpServers(map[string]httpserver.Definer{
"public": publicDefiner,
"private": privateDefiner,
})

Conclusion

In this quick guide, you learned multiple ways to configure your HTTP servers.

Check out these resources to learn more about HTTP server configurations and gosoline: