A Go module to generate the HTTP Link header.
go get github.com/alexferl/httplink
package main
import (
"fmt"
"net/http"
"github.com/alexferl/httplink"
)
func handler(w http.ResponseWriter, r *http.Request) {
httplink.Append(w.Header(), "/things/2842", "next")
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}
Make a request:
curl -i http://localhost:8080
HTTP/1.1 200 OK
Link: </things/2842>; rel=next
Date: Tue, 08 Nov 2022 06:37:22 GMT
Content-Length: 0