Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexferl/httplink
HTTP Link header generator
https://github.com/alexferl/httplink
go golang header http-header http-link http-link-header link link-header
Last synced: about 1 month ago
JSON representation
HTTP Link header generator
- Host: GitHub
- URL: https://github.com/alexferl/httplink
- Owner: alexferl
- License: mit
- Created: 2022-11-08T00:56:09.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2022-11-09T03:46:58.000Z (about 2 years ago)
- Last Synced: 2024-10-14T02:27:09.558Z (3 months ago)
- Topics: go, golang, header, http-header, http-link, http-link-header, link, link-header
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# httplink [![Go Report Card](https://goreportcard.com/badge/github.com/alexferl/httplink)](https://goreportcard.com/report/github.com/alexferl/httplink) [![codecov](https://codecov.io/gh/alexferl/httplink/branch/master/graph/badge.svg)](https://codecov.io/gh/alexferl/httplink)
A Go module to generate the HTTP [Link](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link) header.
## Installing
```shell
go get github.com/alexferl/httplink
```## Using
### Code example
```go
package mainimport (
"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:
```shell
curl -i http://localhost:8080
HTTP/1.1 200 OK
Link: ; rel=next
Date: Tue, 08 Nov 2022 06:37:22 GMT
Content-Length: 0
```## Credits
Port of [this](https://github.com/falconry/falcon/blob/3.1.0/falcon/response.py#L779) [Falcon](https://falconframework.org/) method.