浏览代码

Update V deps (#5420)

* update v deps

* use tag instead of branch
S-YOU 5 年之前
父节点
当前提交
ca769ad8c5
共有 3 个文件被更改,包括 20 次插入17 次删除
  1. 1 1
      frameworks/V/pico.v/benchmark_config.json
  2. 13 8
      frameworks/V/pico.v/main.v
  3. 6 8
      frameworks/V/pico.v/pico.v.dockerfile

+ 1 - 1
frameworks/V/pico.v/benchmark_config.json

@@ -5,7 +5,7 @@
       "default": {
         "json_url": "/j",
         "plaintext_url": "/t",
-        "port": 8080,
+        "port": 8088,
         "approach": "Realistic",
         "classification": "Micro",
         "database": "None",

+ 13 - 8
frameworks/V/pico.v/main.v

@@ -8,29 +8,34 @@ struct Message {
 
 [inline]
 fn json_response() string {
-	msg := Message{message: "Hello, World!"}
+	msg := Message{
+		message: 'Hello, World!'
+	}
 	return json.encode(msg)
 }
 
 [inline]
 fn hello_response() string {
-	return "Hello, World!"
+	return 'Hello, World!'
 }
 
 pub fn callback(req hp.Request, res mut hp.Response) {
-	if hp.cmp(req.method, "GET") {
-		if hp.cmp(req.path, "/t") {
+	if hp.cmpn(req.method, 'GET ', 4) {
+		if hp.cmp(req.path, '/t') {
 			res.http_ok().header_server().header_date().plain().body(hello_response())
-		} else if hp.cmp(req.path, "/j") {
+		}
+		else if hp.cmp(req.path, '/j') {
 			res.http_ok().header_server().header_date().json().body(json_response())
-		} else {
+		}
+		else {
 			res.http_404()
 		}
-	} else {
+	}
+	else {
 		res.http_405()
 	}
 }
 
 pub fn main() {
-	picoev.new(8080, &callback).serve()
+	picoev.new(8088, &callback).serve()
 }

+ 6 - 8
frameworks/V/pico.v/pico.v.dockerfile

@@ -1,15 +1,13 @@
-FROM debian:sid
+FROM syou/v-dev:0.1
 
 WORKDIR /app
 
-RUN apt-get update -yqq && apt-get install wget unzip build-essential ca-certificates git --no-install-recommends --yes -yqq
-RUN wget -q https://github.com/vlang/v/releases/download/0.1.24/v_linux.zip && unzip -q v_linux.zip -d ./v/ && rm v_linux.zip
-
 COPY ./main.v run.sh ./
 
-RUN git clone https://github.com/S-YOU/pico.v src && cd src && git checkout v0.0.3
-RUN cd src/picoev && git clone https://github.com/S-YOU/picoev src && cd src && git checkout 311fb2c2a148baca7b7fad33afa94e4558c63478
-RUN cd src/picohttpparser && git clone https://github.com/h2o/picohttpparser src && cd src && git checkout 81fe3d99fd90a55cafb993e53fd3000dbc4d564c
-RUN mkdir -p /root/.vmodules/ && ln -s /app/src /root/.vmodules/syou && ./v/v -prod -cflags '-std=gnu11 -Wall -O3 -march=native -mtune=native -flto' main.v
+RUN git clone https://github.com/S-YOU/pico.v src && cd src && git checkout v0.0.4 \
+    && cd /app/src/picoev && git clone https://github.com/S-YOU/picoev src && cd src && git checkout v0.0.1 \
+    && cd /app/src/picohttpparser && git clone https://github.com/S-YOU/picohttpparser src && cd src && git checkout v0.0.1 \
+    && ln -s /app/src /root/.vmodules/syou \
+    && cd /app && v -prod -cflags '-std=gnu11 -Wall -O3 -march=native -mtune=native -flto' main.v
 
 CMD sh run.sh