Skip to content

Instantly share code, notes, and snippets.

@gnilchee
Created July 4, 2016 06:00
Show Gist options
  • Save gnilchee/76212596e9adedb475080051d47ce839 to your computer and use it in GitHub Desktop.
Save gnilchee/76212596e9adedb475080051d47ce839 to your computer and use it in GitHub Desktop.
HTTP server with single subdomain and naked domain (no wildcards)
package main
import (
"github.com/kataras/iris"
)
func main() {
api := iris.New()
//your subdomain
subdomain := api.Party("subdomain.")
{
subdomain.Get("/", func(c *iris.Context) {
c.Write("Index of subdomain.mydomain.com")
})
subdomain.Get("/ping", func(c *iris.Context) {
c.Write("pong from subdomain.mydomain.com")
})
}
//naked domain
api.Get("/", func(c *iris.Context) {
c.Write("Index, no subdomain")
})
api.Get("/ping", func(c *iris.Context) {
c.Write("pong")
})
api.Listen("mydomain.com:8080")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment