initial commit
This commit is contained in:
commit
9076bc9d73
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "happy",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-babel": "^3.9.0",
|
||||
"@vue/cli-plugin-typescript": "^3.9.0",
|
||||
"@vue/cli-service": "^3.9.0"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
Arguments:
|
||||
/usr/local/Cellar/node/12.8.0/bin/node /Users/cws/.yarn/bin/yarn.js
|
||||
|
||||
PATH:
|
||||
/Users/cws/src/github.com/chrissexton/happy/pub/happy/node_modules/.bin:/Users/cws/src/github.com/chrissexton/happy/pub/node_modules/.bin:/Users/cws/src/github.com/chrissexton/happy/node_modules/.bin:/Users/cws/src/github.com/chrissexton/node_modules/.bin:/Users/cws/src/github.com/node_modules/.bin:/Users/cws/src/node_modules/.bin:/Users/cws/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/usr/local/Cellar/node/12.8.0/bin:/Users/cws/.yarn/bin:/Users/cws/.config/yarn/global/node_modules/.bin:/usr/local/opt/icu4c/sbin:/usr/local/opt/icu4c/bin:/Users/cws/Library/Python/3.6/bin:/Users/cws/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Library/Apple/bin:/Library/TeX/texbin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/local/opt/python/libexec/bin:/Users/cws/.rbenv/shims:/Users/cws/bin:/Users/cws/go/bin:/usr/local/games:/usr/local/sbin:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/qt4/bin:/Users/cws/src/go/bin:/Library/Frameworks/Mono.framework/Versions/Current/bin:/Users/cws/.rvm/bin:/Library/TeX/texbin/:/Users/cws/.please:/Users/cws/.rvm/bin:/Users/cws/.fzf/bin:/Users/cws/go/bin
|
||||
|
||||
Yarn version:
|
||||
1.15.2
|
||||
|
||||
Node version:
|
||||
12.8.0
|
||||
|
||||
Platform:
|
||||
darwin x64
|
||||
|
||||
Trace:
|
||||
Error: getaddrinfo ENOTFOUND registry.yarnpkg.com
|
||||
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:60:26)
|
||||
|
||||
npm manifest:
|
||||
{
|
||||
"name": "happy",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-babel": "^3.9.0",
|
||||
"@vue/cli-plugin-typescript": "^3.9.0",
|
||||
"@vue/cli-service": "^3.9.0"
|
||||
}
|
||||
}
|
||||
|
||||
yarn manifest:
|
||||
No manifest
|
||||
|
||||
Lockfile:
|
||||
No lockfile
|
|
@ -0,0 +1 @@
|
|||
hello
|
|
@ -0,0 +1,11 @@
|
|||
module github.com/chrissexton/happy
|
||||
|
||||
go 1.12
|
||||
|
||||
require (
|
||||
github.com/carbocation/interpose v0.0.0-20161206215253-723534742ba3
|
||||
github.com/gorilla/handlers v1.4.2
|
||||
github.com/gorilla/mux v1.7.3
|
||||
github.com/rs/zerolog v1.15.0
|
||||
github.com/stretchr/graceful v1.2.15
|
||||
)
|
|
@ -0,0 +1,22 @@
|
|||
github.com/carbocation/interpose v0.0.0-20161206215253-723534742ba3 h1:RtCys6GUprNaPOP04Zuo65wS10PMbSPPZNvIb9xYYLE=
|
||||
github.com/carbocation/interpose v0.0.0-20161206215253-723534742ba3/go.mod h1:4PGcghc3ZjA/uozANO8lCHo/gnHyMsm8iFYppSkVE/M=
|
||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/gorilla/handlers v1.4.2 h1:0QniY0USkHQ1RGCLfKxeNHK9bkDHGRYGNDFBCS+YARg=
|
||||
github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
|
||||
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
|
||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
||||
github.com/rs/zerolog v1.15.0 h1:uPRuwkWF4J6fGsJ2R0Gn2jB1EQiav9k3S6CSdygQJXY=
|
||||
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
|
||||
github.com/stretchr/graceful v1.2.15 h1:vmXbwPGfe8bI6KkgmHry/P1Pk63bM3TDcfi+5mh+VHg=
|
||||
github.com/stretchr/graceful v1.2.15/go.mod h1:IxdGAOTZueMKoBr3oJIzdeg5CCCXbHXfV44sLhfAXXI=
|
||||
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
|
@ -0,0 +1,60 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/stretchr/graceful"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.Logger = log.Logger.Output(zerolog.ConsoleWriter{Out: os.Stderr})
|
||||
zerolog.SetGlobalLevel(zerolog.DebugLevel)
|
||||
s := server{"0.0.0.0:8080", "pub"}
|
||||
s.serve()
|
||||
}
|
||||
|
||||
func logger(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
log.Info().
|
||||
Str("Path", r.URL.Path).
|
||||
Str("Method", r.Method).
|
||||
Msg("HTTP Request")
|
||||
})
|
||||
}
|
||||
|
||||
type server struct {
|
||||
addr string
|
||||
assetPath string
|
||||
}
|
||||
|
||||
func (s *server) handleMood(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, "hello")
|
||||
}
|
||||
|
||||
func (s *server) indexHandler(entryPoint string) func(w http.ResponseWriter, r *http.Request) {
|
||||
fn := func(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, entryPoint)
|
||||
}
|
||||
return http.HandlerFunc(fn)
|
||||
}
|
||||
|
||||
func (s *server) routeSetup() *mux.Router {
|
||||
r := mux.NewRouter()
|
||||
api := r.PathPrefix("/v1/").Subrouter()
|
||||
api.HandleFunc("/mood", s.handleMood).Methods("POST")
|
||||
r.PathPrefix("/static").Handler(http.FileServer(http.Dir("dist/")))
|
||||
r.PathPrefix("/").HandlerFunc(s.indexHandler("dist/index.html"))
|
||||
return r
|
||||
}
|
||||
|
||||
func (s *server) serve() {
|
||||
middle := s.routeSetup()
|
||||
log.Info().Str("addr", s.addr).Msg("serving HTTP")
|
||||
graceful.Run(s.addr, 10*time.Second, middle)
|
||||
}
|
Loading…
Reference in New Issue