# Go `_headers` parser

Headers format parser to match Netlify's [`_headers` file format](https://docs.netlify.com/manage/routing/headers/#syntax-for-the-headers-file), plus a compatible unparser.


## Example

```go
package main

import (
    "encoding/json"
    "fmt"

    "codeberg.org/git-pages/go-headers"
)

func main() {
    rules := headers.Must(headers.ParseString(`
# enable COOP/COEP on index:
/index.html
  cross-origin-opener-policy: same-origin
  # breaks some use cases
  cross-origin-embedder-policy: credentialless
# on the worker too:
/worker.js
  cross-origin-embedder-policy: credentialless
/*
  x-content-type-options: nosniff
`))
    data, _ := json.MarshalIndent(rules, "", "  ")
    fmt.Printf("%s", data)
}
```

```json
[
  {
    "Path": "/index.html",
    "Headers": {
      "Cross-Origin-Embedder-Policy": [
        "credentialless"
      ],
      "Cross-Origin-Opener-Policy": [
        "same-origin"
      ]
    }
  },
  {
    "Path": "/worker.js",
    "Headers": {
      "Cross-Origin-Embedder-Policy": [
        "credentialless"
      ]
    }
  },
  {
    "Path": "/*",
    "Headers": {
      "X-Content-Type-Options": [
        "nosniff"
      ]
    }
  }
]
```


## License

[0-clause BSD](LICENSE.txt)
