struCoder / pmgo

pmgo is a process manager for Golang applications.
MIT License
625 stars 65 forks source link

HTML or static .js file rendering issue #30

Closed JeHyunwoo91 closed 6 years ago

JeHyunwoo91 commented 6 years ago

Hi, I always appreciating your pmgo modular.

I have one question, When i start pmgo any web application that has .html or static .js file, client request .html file then server response is non exists.

So, i copied .html file or static .js file in my project source-code directory to ~/.pmgo/{app-name}/. but, still is not working....

So, is pmgo has supported rendering function like .html or static .js file??

best regards.

struCoder commented 6 years ago

Got it. @JeHyunwoo91 i think you need code like this (just demo):


package main

import (
    "fmt"
    "log"
    "net/http"
)

func index(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "Hello golang!")
}

func main() {
    http.HandleFunc("/", index)

    // static files
    hfs := http.FileServer(http.Dir("/path/to/your/static/dir"))
    http.Handle("/static/", http.StripPrefix("/static/", hfs))

    err := http.ListenAndServe(":9090", nil)
    if err != nil {
        log.Fatal("ListenAndServe: ", err)
    }
}