import "somerepo/pkg/sessions"
store = sessions.NewSessionStore(&sessions.SessionConfig{
SessionID: "sess-id",
Timeout: time.Duration(15) * time.Minute,
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
"sort" | |
"strconv" | |
"strings" | |
) |
package ndjson | |
import ( | |
"bytes" | |
"errors" | |
"fmt" | |
"unicode" | |
"unicode/utf8" | |
) |
// Middleware is our type definition of a middleware function. | |
type Middleware func(http.Handler) http.Handler | |
// Tupperware is a basic middleware boilerplate that is of the | |
// `Middleware` type because it has its type signature. | |
func Tupperware(next http.Handler) http.Handler { | |
// `fn` has the type signature of a `http.HandlerFunc` type. | |
fn := func(w http.ResponseWriter, r *http.Request) { | |
// Do http stuff in here, and then choose where you want to | |
// call the next handler in the chain. It could be in here, |
{{ define "title" }}Index Page{{ end }} | |
{{ define "body" }} | |
<div class="container-fluid"> | |
<h1>Welcome to the INDEX page</h1> | |
Feel free to check out my <a href="/home">home</a> page! | |
</div> | |
{{ end }} |
package main | |
import ( | |
"fmt" | |
"log" | |
"os" | |
"time" | |
) | |
// this is version 1 |
package filewatcher | |
import ( | |
"fmt" | |
"io/fs" | |
"log" | |
"os" | |
"path/filepath" | |
"regexp" | |
"strings" |
func RunSimpleHTTPServer(addr, path string) { | |
// setup logger | |
l := log.New(os.Stderr, "", log.LstdFlags) | |
// check args | |
if addr == "" { | |
l.Panicln(errors.New("no listening address specified")) | |
} | |
// get current dir | |
wd, err := os.Getwd() | |
if err != nil { |
package main | |
import ( | |
"encoding/json" | |
"encoding/xml" | |
"fmt" | |
"log" | |
"net/http" | |
"net/url" | |
"strings" |
package main | |
import ( | |
"fmt" | |
"strings" | |
) | |
func main() { | |
// 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 | |
l := NewLRU(3) |