<commit_before>Argonaut
========

A JSON REST API in Go.

### Quick Start

An API is an empty placeholder for collections. Create one using:

```go
import "github.com/aodin/argonaut"

api, _ := argonaut.API("/api/")
```

The API can now be attached to Go's default HTTP route multiplexer using:

```go
http.Handle(api.BaseURL(), api)
```

This API is empty. Navigating to the URL `/api/` will return an empty list of resources.

To attach a resource, first declare a schema:

```go
import "github.com/aodin/argonaut"

var item = argonaut.Resource("item",
    argonaut.Field("id", argonaut.Integer{}),
    argonaut.Field("name", argonaut.String{Required: true}),
)
```

Or you can directly import the package into the default namespace using `.`:

```go
import . "github.com/aodin/argonaut"

var item = Resource("item",
    Field("id", Integer{}),
    Field("name", String{Required: true}),
)
```

This schema is used to create a collection. For now, there's an example in-memory key-value store. More to come.

```go
items := IntegerStore(item)
resourceErr := endpoint.Register("item", items)
```

This will expose standard REST methods at the URL `/api/items/`.

A full example looks like:

```go
package main

import (
    "log"
    "net/http"
    "github.com/aodin/argonaut"
)

var item = argonaut.Resource("item",
    argonaut.Field("id", argonaut.Integer{}),
    argonaut.Field("name", argonaut.String{Required: true}),
)

func main() {
    // Create an item and register the item schema
    endpoint, apiErr := argonaut.API("/api")
    if apiErr != nil {
        panic("Could not create the specified API")
    }

    // Attach it to the handler
    http.Handle(endpoint.BaseURL(), endpoint)

    items := argonaut.IntegerStore(item)<commit_msg>Corrected error in example README URL<commit_after>Argonaut
========

A JSON REST API in Go.

### Quick Start

An API is an empty placeholder for collections. Create one using:

```go
import "github.com/aodin/argonaut"

api, _ := argonaut.API("/api/")
```

The API can now be attached to Go's default HTTP route multiplexer using:

```go
http.Handle(api.BaseURL(), api)
```

This API is empty. Navigating to the URL `/api/` will return an empty list of resources.

To attach a resource, first declare a schema:

```go
import "github.com/aodin/argonaut"

var item = argonaut.Resource("item",
    argonaut.Field("id", argonaut.Integer{}),
    argonaut.Field("name", argonaut.String{Required: true}),
)
```

Or you can directly import the package into the default namespace using `.`:

```go
import . "github.com/aodin/argonaut"

var item = Resource("item",
    Field("id", Integer{}),
    Field("name", String{Required: true}),
)
```

This schema is used to create a collection. For now, there's an example in-memory key-value store called `IntegerStore`. More to come.

```go
items := IntegerStore(item)
resourceErr := endpoint.Register("item", items)
```

This will expose standard REST methods at the URL `/api/item/`.

A full example looks like:

```go
package main

import (
    "log"
    "net/http"
    "github.com/aodin/argonaut"
)

var item = argonaut.Resource("item",
    argonaut.Field("id", argonaut.Integer{}),
    argonaut.Field("name", argonaut.String{Required: true}),
)

func main() {
    // Create an item and register the item schema
    endpoint, apiErr := argonaut.API("/api")
    if apiErr != nil {
        panic("Could not create the specified API")
    }

    // Attach it to the handler
    http.Handle(endpoint.BaseURL(), endpoint)

    items := argonaut.IntegerStore(item)
{'fraction_non_alphanumeric': 0.14152805187482378, 'fraction_numerical': 0.0, 'mean_word_length': 3.8206521739130435, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7068373', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1090, 'n_words': 376}