An open API service indexing awesome lists of open source software.

https://github.com/xiaojianzhong/gokoa

Koa styled web framework written in Go.
https://github.com/xiaojianzhong/gokoa

golang koa nodejs webframework

Last synced: about 2 months ago
JSON representation

Koa styled web framework written in Go.

Awesome Lists containing this project

README

          

# GoKoa

![GitHub Workflow Status](https://img.shields.io/github/workflow/status/xiaojianzhong/gokoa/Golang)
![GitHub repo size](https://img.shields.io/github/repo-size/xiaojianzhong/gokoa)
![GitHub last commit](https://img.shields.io/github/last-commit/xiaojianzhong/gokoa)
![GitHub](https://img.shields.io/github/license/xiaojianzhong/gokoa)

[Koa][koa] styled web framework written in Go.

Read this in other languages: English | [简体中文](./README_zh-CN.md)

## Table of Contents

- [Introduction](#introduction)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [What Are NOT Implemented](#what-are-not-implemented)
- [Documentation](#documentation)
- [`Application`](#application)
- [`Context`](#context)
- [`Request`](#request)
- [`Response`](#response)
- [Development](#development)
- [How to Test](#how-to-test)

## Introduction

[GoKoa](gokoa) is a Koa styled web framework, which aims at reducing learning cost in grasping web development in Go for Node.js developers.

GoKoa is written in Go, which is beneficial to improving performance in handling HTTP requests.

## Prerequisites

1. [Go](go) >= 1.13

## Installation

You can easily fetch the newest version of GoKoa by executing `go get`:

```bash
$ go get github.com/xiaojianzhong/gokoa
```

## Quick Start

```go
package main

import (
"github.com/xiaojianzhong/gokoa"
)

func main() {
app := gokoa.NewApplication(nil)

app.Use(func(ctx *gokoa.Context, fn func() error) error {
ctx.SetBody("hello gokoa")
return nil
})

app.Listen(8080)
}
```

## What Are NOT Implemented

1. lack of event emitting, except for `app.OnError()`
2. not able to customize HTTP reason phrase (don't do that cause it breaks the best practice)
3. not able to bypass GoKoa's response handling (actually it is deprecated by Koa, too)
4. not able to access the socket related to a HTTP connection
5. lack of `headerSent` property

## Documentation

### `Application`

### `Context`

### `Request`

### `Response`

## Development

### How To Test

You can easily run unit tests by executing `go test`:

```bash
$ go test github.com/xiaojianzhong/gokoa
```

[koa]: https://github.com/koajs/koa
[go]: https://golang.org/
[gokoa]: https://github.com/xiaojianzhong/gokoa