mirror of
https://github.com/kataras/iris.git
synced 2026-01-03 18:27:07 +00:00
reorganization of _examples and add some new examples such as iris+groupcache+mysql+docker
Former-commit-id: ed635ee95de7160cde11eaabc0c1dcb0e460a620
This commit is contained in:
27
_examples/routing/subdomains/single/hosts
Normal file
27
_examples/routing/subdomains/single/hosts
Normal file
@@ -0,0 +1,27 @@
|
||||
# Copyright (c) 1993-2009 Microsoft Corp.
|
||||
#
|
||||
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
|
||||
#
|
||||
# This file contains the mappings of IP addresses to host names. Each
|
||||
# entry should be kept on an individual line. The IP address should
|
||||
# be placed in the first column followed by the corresponding host name.
|
||||
# The IP address and the host name should be separated by at least one
|
||||
# space.
|
||||
#
|
||||
# Additionally, comments (such as these) may be inserted on individual
|
||||
# lines or following the machine name denoted by a '#' symbol.
|
||||
#
|
||||
# For example:
|
||||
#
|
||||
# 102.54.94.97 rhino.acme.com # source server
|
||||
# 38.25.63.10 x.acme.com # x client host
|
||||
|
||||
# localhost name resolution is handled within DNS itself.
|
||||
127.0.0.1 localhost
|
||||
::1 localhost
|
||||
#-iris-For development machine, you have to configure your dns also for online, search google how to do it if you don't know
|
||||
|
||||
127.0.0.1 mydomain.com
|
||||
127.0.0.1 admin.mydomain.com
|
||||
|
||||
#-END iris-
|
||||
44
_examples/routing/subdomains/single/main.go
Normal file
44
_examples/routing/subdomains/single/main.go
Normal file
@@ -0,0 +1,44 @@
|
||||
// Package main register static subdomains, simple as parties, check ./hosts if you use windows
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris/v12"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := iris.New()
|
||||
|
||||
// Subdomain method is just another Party.
|
||||
admin := app.Subdomain("admin")
|
||||
{
|
||||
// admin.mydomain.com
|
||||
admin.Get("/", func(c iris.Context) {
|
||||
c.Writef("INDEX FROM admin.mydomain.com")
|
||||
})
|
||||
// admin.mydomain.com/hey
|
||||
admin.Get("/hey", func(c iris.Context) {
|
||||
c.Writef("HEY FROM admin.mydomain.com/hey")
|
||||
})
|
||||
// admin.mydomain.com/hey2
|
||||
admin.Get("/hey2", func(c iris.Context) {
|
||||
c.Writef("HEY SECOND FROM admin.mydomain.com/hey")
|
||||
})
|
||||
}
|
||||
|
||||
// mydomain.com
|
||||
app.Get("/", func(c iris.Context) {
|
||||
c.Writef("INDEX FROM no-subdomain hey")
|
||||
})
|
||||
|
||||
// mydomain.com/hey
|
||||
app.Get("/hey", func(c iris.Context) {
|
||||
c.Writef("HEY FROM no-subdomain hey")
|
||||
})
|
||||
|
||||
// http://admin.mydomain.com
|
||||
// http://admin.mydomain.com/hey
|
||||
// http://admin.mydomain.com/hey2
|
||||
// http://mydomain.com
|
||||
// http://mydomain.com/hey
|
||||
app.Listen("mydomain.com:80") // for beginners: look ../hosts file
|
||||
}
|
||||
Reference in New Issue
Block a user