Skip to content

Instantly share code, notes, and snippets.

@jpoehls
Created July 27, 2015 16:20
Show Gist options
  • Select an option

  • Save jpoehls/a40db92ad2033ab7316f to your computer and use it in GitHub Desktop.

Select an option

Save jpoehls/a40db92ad2033ab7316f to your computer and use it in GitHub Desktop.

Revisions

  1. jpoehls created this gist Jul 27, 2015.
    15 changes: 15 additions & 0 deletions Caddyfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    # Caddyfile

    localhost:2015 {
    startup "go run ./server.go" &
    root ./static_files
    proxy / localhost:2016
    }

    # FILE TREE
    #
    # │ Caddyfile
    # │ server.go
    # │
    # └───static_files
    # styles.css
    27 changes: 27 additions & 0 deletions server.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    // server.go

    package main

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

    func main() {
    http.HandleFunc("/", handler)
    log.Fatalln(http.ListenAndServe(":2016", nil))
    }

    func handler(w http.ResponseWriter, r *http.Request) {
    fmt.Fprint(w, `
    <html>
    <head>
    <link href="/styles.css" rel="stylesheet" />
    </head>
    <body>
    My background should be blue.
    </body>
    </html>
    `)
    }
    5 changes: 5 additions & 0 deletions styles.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    /* static_files/styles.css */

    body {
    background-color: blue;
    }