Skip to content

alexferl/httplink

Repository files navigation

httplink Go Report Card codecov

A Go module to generate the HTTP Link header.

Installing

go get github.com/alexferl/httplink

Using

Code example

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

Credits

Port of this Falcon method.