Skip to content

Instantly share code, notes, and snippets.

View workflow.yml
name: Audit and deploy
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
View workflow.yml
name: Audit
on:
push:
branches:
- main
pull_request:
branches:
- main
@alexedwards
alexedwards / index.html
Last active Sep 17, 2021
HTML skeleton
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Your Page Title</title>
<meta name="description" content="Brief description">
<meta name="author" content="Your name">
View gist:fa02ec95402f687e5f08f54a575a55c7
func (app *application) showMovieHandler(w http.ResponseWriter, r *http.Request) {
id, err := app.readIDParam(r)
if err != nil {
// IT'S THIS LINE HERE THAT YOU NEED TO CHANGE to use the new notFoundResponse() helper.
app.notFoundResponse(w, r)
return
}
movie := data.Movie{
ID: id,
CreatedAt: time.Now(),
View gist:41f7e747ee10287bb881fab9e36ed07c
package main
import (
"net/http"
"github.com/bmizerany/pat"
"github.com/justinas/alice"
)
func (app *application) routes() http.Handler {
View gist:3e158aba800a3044f31bda3d32c72c56
package jsonlog
import (
"encoding/json"
"io"
"os"
"runtime/debug"
"sync"
"time"
)
View gist:a175f4da955cbf57cf2c10f6798a8a6f
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>Simple CORS</h1>
<output></output>
<script>
document.addEventListener('DOMContentLoaded', function() {
@alexedwards
alexedwards / main.go
Created Nov 15, 2020
JSON decoding benchmarks
View main.go
package main
import (
"encoding/json"
"io/ioutil"
"net/http"
)
func createMovieHandlerUnmarshal(w http.ResponseWriter, r *http.Request) {
var input struct {
@alexedwards
alexedwards / main.go
Created Nov 10, 2020
JSON encoding benchmarks #2
View main.go
package main
import (
"encoding/json"
"net/http"
)
func main() {}
func healthcheckHandlerMarshalIndent(w http.ResponseWriter, r *http.Request) {
@alexedwards
alexedwards / main.go
Last active May 4, 2022
JSON encoding benchmarks
View main.go
package main
import (
"encoding/json"
"net/http"
)
func main() {}
func healthcheckHandlerEncoder(w http.ResponseWriter, r *http.Request) {