<commit_before>restapi
=======

A simple RESTful Api<commit_msg>Add simple doc<commit_after>#Simple API

	package main

	import (
		"github.com/elsonwu/restapi"
	)

	type User struct {
		restapi.Api
	}

	//in this demo, we only allow view method
	func (self *User) View(ctx restapi.IContext) restapi.IOutput {
	    //result, data,        errors
	    //bool,   interface{}, []string
		return restapi.Output(true, ctx.Query(), nil)
	}


	func main() {
		restapi.Add("user", &User{})
		restapi.Run(":8888")
	}
	
	//Visit http://localhost:8888/user/xxx
	{
    	"data": {
        	"id": [
            	"xxx"
        	]
    	},
    	"errors": null,
    	"result": true
	}
	
#API calls another API

    //user api create method calls content api view method.
	func (self *User) Create(ctx restapi.IContext) restapi.IOutput {
		query := ctx.Query()
		query.Add("with_content_comments", "1")
		return restapi.Call("content", restapi.MethodView, ctx)
	}
{'fraction_non_alphanumeric': 0.1474019088016967, 'fraction_numerical': 0.009544008483563097, 'mean_word_length': 2.8218623481781377, 'pattern_counts': {'":': 5, '<': 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': '5117158', 'n_tokens_mistral': 355, 'n_tokens_neox': 327, 'n_words': 81}