All Projects → AdhityaRamadhanus → fasthttpcors

AdhityaRamadhanus / fasthttpcors

Licence: MIT License
Cors Handler for fasthttp

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to fasthttpcors

go-movies
golang spider Crawler 爬虫 电影
Stars: ✭ 168 (+740%)
Mutual labels:  fasthttp
nicks-cors-test
Simple HTML & JS Tool to quickly test CORS locally.
Stars: ✭ 68 (+240%)
Mutual labels:  cors
gmocker
Create a blazing fast mock server with just a JSON file
Stars: ✭ 49 (+145%)
Mutual labels:  fasthttp
horse-cors
No description or website provided.
Stars: ✭ 31 (+55%)
Mutual labels:  cors
node-cors-client
A test application that helps illustrate CORS while both in a working state and a non-working state across simple and complex request scenarios.
Stars: ✭ 53 (+165%)
Mutual labels:  cors
ticker-phoenix
Elixir Phoenix Stock Quotes API (IEX Trading)
Stars: ✭ 15 (-25%)
Mutual labels:  cors
poop
Firefox extension that prevents sending Origin headers when they are least likely to be necessary, to protect your privacy.
Stars: ✭ 36 (+80%)
Mutual labels:  cors
gobang04
五子棋社区,前后端完全分离,SSM框架,CORS跨域访问,SSO单点登录,Bootstrap界面,RESTful构架风格,Netty即时通信,Token口令授权,Web端与客户端通信。异步请求,面向接口编程。
Stars: ✭ 14 (-30%)
Mutual labels:  cors
create-fastify-app
An utility that help you to generate or add plugin to your Fastify project
Stars: ✭ 53 (+165%)
Mutual labels:  cors
rester
Fast and concise RESTful web framework based on fasthttp
Stars: ✭ 27 (+35%)
Mutual labels:  fasthttp
silverstripe-graphql-jwt
JWT Authentication for GraphQL
Stars: ✭ 17 (-15%)
Mutual labels:  cors
nginx-cors-plus
A simple nginx proxy that you can put in front of any domain to enable CORS.
Stars: ✭ 32 (+60%)
Mutual labels:  cors
fastify-cors
Fastify CORS
Stars: ✭ 212 (+960%)
Mutual labels:  cors
koa-restful-boilerplate
A boilerplate for koa2 RESTful API development
Stars: ✭ 31 (+55%)
Mutual labels:  cors
fs-over-http
A filesystem interface over http, with extras and docker support
Stars: ✭ 14 (-30%)
Mutual labels:  fasthttp
lua-resty-cors
It's the implement of CORS on OpenResty
Stars: ✭ 53 (+165%)
Mutual labels:  cors
vapi
vAPI is Vulnerable Adversely Programmed Interface which is Self-Hostable API that mimics OWASP API Top 10 scenarios through Exercises.
Stars: ✭ 674 (+3270%)
Mutual labels:  cors
cors
Deno.js CORS middleware.
Stars: ✭ 46 (+130%)
Mutual labels:  cors
SecExample
JAVA 漏洞靶场 (Vulnerability Environment For Java)
Stars: ✭ 228 (+1040%)
Mutual labels:  cors
BugHunter
No description or website provided.
Stars: ✭ 23 (+15%)
Mutual labels:  cors

fasthttpcors

Go Report Card

Cors handler for fasthttp server

Read First | Installation | Usage | License

Handling CORS in fasthttp

Read First

Installation

  • go get github.com/adhityaramadhanus/fasthttpcors

Usage

package main

import (
	"log"

	cors "github.com/AdhityaRamadhanus/fasthttpcors"
	"github.com/valyala/fasthttp"
)

func main() {
	withCors := cors.NewCorsHandler(cors.Options{
		// if you leave allowedOrigins empty then fasthttpcors will treat it as "*"
		AllowedOrigins: []string{"http://example.com"}, // Only allow example.com to access the resource
		// if you leave allowedHeaders empty then fasthttpcors will accept any non-simple headers
		AllowedHeaders: []string{"x-something-client", "Content-Type"}, // only allow x-something-client and Content-Type in actual request
		// if you leave this empty, only simple method will be accepted
		AllowedMethods:   []string{"GET", "POST"}, // only allow get or post to resource
		AllowCredentials: false,                   // resource doesn't support credentials
		AllowMaxAge:      5600,                    // cache the preflight result
		Debug:            true,
	})
	if err := fasthttp.ListenAndServe(":8080", withCors.CorsMiddleware(RequestHandler)); err != nil {
		log.Fatalf("Error in ListenAndServe: %s", err)
	}
}

func RequestHandler(ctx *fasthttp.RequestCtx) {
	ctx.SetContentType("plain/text")
	ctx.SetStatusCode(200)
	ctx.SetBodyString("OK")
}

TODO

  • add test

License

MIT © [Adhitya Ramadhanus]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].