httpmuxes

package module
v0.0.0-...-b6221ca Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2019 License: Apache-2.0 Imports: 1 Imported by: 0

README

go-httpmuxes

Add same urls to several http.NewServeMux

package main

import (
    httpmuxes "github.com/9glt/go-httpmuxes"
    "net/http"
    "log"
)
func main() {
    httpmuxes.Register("https", http.NewServeMux())
    httpmuxes.Register("http", http.NewServeMux())
    // ....

    httpmuxes.HandleFuncAll("/http-https", func(w http.ResponseWriter, r *http.Request){
        w.Write([]byte("hi"))
    })

    httpmuxes.HandleFunc("/http", func(w http.ResponseWriter, r *http.Request) {
        w.Write([]byte("hi http"))
    }, []string{"http"})

    httpmuxes.HandleFunc("/https", func(w http.ResponseWriter, r *http.Request) {
        w.Write([]byte("hi https"))
    }, []string{"https"})

    // ...

    go func() { log.Fatal(http.ListenAndServe(":80", httpmuxes.Get("http"))}) 
    log.Fatal(http.ListenAndServe(":443", httpmuxes.Get("https")))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(name string) *http.ServeMux

func HandleFunc

func HandleFunc(path string, fn http.HandlerFunc, muxs []string)

func HandleFuncAll

func HandleFuncAll(path string, fn http.HandlerFunc)

func Register

func Register(name string, mux *http.ServeMux)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL