Created
July 4, 2016 06:00
-
-
Save gnilchee/76212596e9adedb475080051d47ce839 to your computer and use it in GitHub Desktop.
HTTP server with single subdomain and naked domain (no wildcards)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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