merp/server.go

36 lines
755 B
Go

//3456789112345676892123456789312345678941234567895123456789612345678971234567898
package main
import "fmt"
import "os"
import "github.com/rs/zerolog/log"
import "github.com/hoisie/web"
/* func initDb() {
db, err := sql.Open("postgres", os.Getenv("POSTGRES_DB_URL"))
if err != nil {
log.Fatal().Msg(err)
}
}
*/
const defaultPort int = 8080
func serve() {
port := os.Getenv("PORT")
if port == "" {
port = fmt.Sprintf("%d", defaultPort)
}
// FIXME web.SetLogger(log.Logger)
web.Get(`/dweet/for/([A-Za-z0-9\-\_\.]+)`, dweetHandler)
web.Run(fmt.Sprintf("0.0.0.0:%s", port))
}
func dweetHandler(ctx *web.Context, val string) string {
log.Info().Msg("in hello()")
for k, v := range ctx.Params {
println(k, v)
}
return ("hello " + val)
}